Skip to content

fix:记忆更新出错 - #567

Open
Orsted290 wants to merge 1 commit into
MemTensor:memmy_1031/v1.2.0from
Orsted290:fix-memory-patch-line-count
Open

Orsted290 wants to merge 1 commit into
MemTensor:memmy_1031/v1.2.0from
Orsted290:fix-memory-patch-line-count

Conversation

@Orsted290

Copy link
Copy Markdown

更新只有一行的工作记忆时,apply_patch 报 hunk at line 3 was not found。文件实际只有 1 行,read_file 却把末尾换行多显示成空白的第 2 行。模型按这个结果写补丁,上下文对不上。报错里的 line 3 是补丁文本中 @@ 所在行,不是文件第 3 行。

apply_patch 会丢掉末尾换行带来的空行,read_file 以前不会。这次让 read_file 使用同样的切行规则:末尾换行不再多出一行,文件里真实的空行仍然保留。

样例是合成的 memory.md,不是原始那份 .workbuddy/memory/2026-09-22.md。内容为 only one memory line 加换行时,只显示第 1 行,没有第 2 行。内容为 first 后面接一个真实空行时,第 2 行空行仍在,不会再出现第 3 行。

A trailing newline was shown as an extra blank line, so patches against one-line memory files failed to match.

Co-authored-by: Cursor <cursoragent@cursor.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant