From ed5eb88ba957f5540be8c1419423a445f41b9de0 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Wed, 9 Sep 2026 20:33:07 +0300 Subject: [PATCH] C-j fix; tool doc upd --- README.md | 8 ++++---- main.go | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 962e8fe..d27e78d 100644 --- a/README.md +++ b/README.md @@ -166,12 +166,12 @@ When enabled, the interactive console uses a subtle ANSI palette: the pending-re #### `write_file` tool - Parameters: - - `path` (string, required): JSON-escaped file path to write to (must be created unless existing). - - `offset` (integer, optional, default 0): byte offset to start writing from (defaults to 0, start of file; does not append). - - `del_bytes` (integer, optional, default 0): bytes to delete starting from the `offset` prior to writing. + - `path` (string, required): JSON-escaped file path to write to. + - `offset` (integer, optional): byte offset to start writing from. If omitted together with `del_bytes`, the whole file is overwritten instead. Defaults to 0 (start of file). + - `del_bytes` (integer, optional): bytes to delete starting at `offset`. If omitted together with `offset`, the whole file is overwritten instead. - `content` (string, required, may be empty): JSON-escaped content to write to the file. - Return value: string -- Action: write `content` into the file at `path` starting at `offset` after deleting `del_bytes` bytes (creating the file and any necessary parent directories). +- Action: if `offset` and `del_bytes` are both omitted, the entire file is overwritten with `content` (the file, and any necessary parent directories, are created if missing); otherwise `content` is written at `offset`, optionally deleting `del_bytes` bytes first (splicing prefix + content + suffix and never appending to the end of an existing file), creating the file and parent directories as needed. #### `shell_exec` tool diff --git a/main.go b/main.go index 765a0ed..a014720 100644 --- a/main.go +++ b/main.go @@ -1598,7 +1598,10 @@ func (e *editor) draw() { er, _ := textPos(P, W, s, len([]rune(s))) pr, pc := textPos(P, W, s, e.pos) if e.crow > 0 { fmt.Printf("\033[%dA", e.crow) } - fmt.Print("\r\033[J" + e.prompt + s) + // In raw mode OPOST is off, so a bare \n only moves down without + // returning to column 0. Emit \r\n so each logical line starts at + // column 0, matching the column-reset assumption in textPos(). + fmt.Print("\r\033[J" + e.prompt + strings.ReplaceAll(s, "\n", "\r\n")) if up := er - pr; up > 0 { fmt.Printf("\033[%dA", up) } fmt.Print("\r") if pc > 0 { fmt.Printf("\033[%dC", pc) }