mirror of
https://github.com/patriceckhart/zot.git
synced 2026-06-27 05:46:34 +02:00
A 200-line paste (log, stack trace, config blob) used to expand the editor to 200 visible rows, burying the rest of the tui and making the prompt awkward to edit. Now a paste of 3+ lines is replaced in the editor with a short token like [pasted text #1 +56 lines] while the full body is stashed behind the scenes and expanded back in right before the turn goes to the agent. Single-line and two-line pastes fall through to the old inline insert path (drag-dropped file paths, short snippets) so those still work as before. Implementation Editor gained two private fields: - pastes map[int]string full bodies keyed by id - pasteSeq int monotonic id counter KeyPaste branch: on content with >= 2 newlines, allocates the next id, stores the raw body, inserts the placeholder token at the cursor. Everything else stays on the existing quotePastedFilePaths path. Editor.Value() returns what's visible (placeholder). Editor.SubmitValue() new method: runs pastePlaceholderRE over the visible text and swaps each match for its stored body. Called once at submit time; non-destructive so history recall (up-arrow) still shows the placeholder form, not the replay. Editor.Clear() drops the pastes map + resets pasteSeq so ids from a previous turn can't leak. SetValue() same reset: pastes map is tied to the visible text and a SetValue replaces it. interactive.go the one caller that reads the editor to build a prompt now reads Value() for the history entry and SubmitValue() for the string that goes to the agent. Tests paste_collapse_test.go covers: - placeholder shape + SubmitValue expansion - single-line and two-line pastes skip the collapse path - two separate pastes get distinct ids, both expand - Clear() resets the map + counter Tweaked the pre-existing TestEditorCursorAfterMultilinePaste and TestEditorCursorAfterLongPasteWithWrap to use Editor.Insert directly so they keep testing wrap / cursor math rather than accidentally exercising the new collapse path. |
||
|---|---|---|
| .. | ||
| editor.go | ||
| highlight.go | ||
| image.go | ||
| input.go | ||
| markdown.go | ||
| partialjson.go | ||
| partialjson_test.go | ||
| paste_collapse_test.go | ||
| quote_paste_test.go | ||
| render.go | ||
| resize_unix.go | ||
| resize_windows.go | ||
| statusbar_test.go | ||
| terminal.go | ||
| theme.go | ||
| view.go | ||
| wrap_test.go | ||