mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-17 11:07:11 +08:00
The Read tool documents that a negative offset reads from the end (-N = last N lines). Content is split on newline, so a file ending in a newline produces a trailing empty element and total_file_lines is one too high. Every negative offset was therefore off by one: offset=-1 returned the empty string after the final newline instead of the last line, and -N returned N-1 real lines. Exclude the trailing empty element when computing the start line for negative offsets. Adds regression tests. Co-authored-by: Cursor <cursoragent@cursor.com>
2.2 KiB
2.2 KiB