Commit Graph

94 Commits

Author SHA1 Message Date
haoqixu eb01f59dc9 fix(tui): wrap CJK text at character boundaries in editor 2026-06-10 15:39:44 +08:00
Mario Zechner b7e721cb38 feat(tui): support autocomplete trigger characters
closes #4703
2026-06-09 14:15:39 +02:00
Mario Zechner e4907b3b09 fix(tui): restore prompt draft after history browsing
closes #5494
2026-06-09 13:06:13 +02:00
Mario Zechner 22e4549275 Merge pull request #5283 from smoosex/main
fix(tui): keep hardware cursor marker during slash-command autocomplete
2026-06-09 12:33:15 +02:00
Roman Galeev 9d007fe642 fix(tui): re-query autocomplete picker on cursor movement
moveCursor() repositioned the cursor but never called updateAutocomplete()
or cancelAutocomplete(), unlike insertCharacter()/handleBackspace(). So an
open autocomplete picker went stale when the cursor moved: e.g. typing
`/cmd ` (argument menu open) then arrowing Left back into the command name
left the argument list showing against a `/cmd` prefix, and a Tab there
concatenated the stale suggestion onto the partial command name
(e.g. `/swarepo`).

Sync the picker at the end of moveCursor(): when a picker is open, re-query
via updateAutocomplete(), which refreshes the list for the new cursor
position or closes it when nothing matches.

Adds a regression test in test/editor.test.ts (verified to fail without the
fix). Fixes earendil-works/pi#5496.
2026-06-08 10:57:50 +02:00
Mario Zechner 59d7025668 fix(tui): position cursor for prompt history navigation
closes #5454
2026-06-07 10:56:09 +02:00
smoose c8df99a795 fix(tui): keep hardware cursor marker during slash-command autocomplete
Remove the !autocompleteState guard so CURSOR_MARKER is still emitted
while the slash-command menu is visible. This lets the TUI position the
hardware cursor correctly, which fixes IME candidate-window placement
for CJK input methods.
2026-05-29 10:00:59 +08:00
xu0o0 701801dec2 fix(tui): align input word segmentation with editor (#5068) 2026-05-27 20:50:04 +02:00
xu0o0 b62776e4a2 fix(tui): preserve ASCII punctuation word boundaries with Intl.Segmenter (#5067) 2026-05-27 12:12:10 +02:00
xu0o0 4402100830 fix(tui): leverage Intl.Segmenter for proper Unicode word boundaries (#5022) 2026-05-27 00:28:47 +02:00
Armin Ronacher ae9450dc51 chore(ts): use source import extensions 2026-05-20 00:04:03 +02:00
Georgi d06db09a53 fix(tui): decode CSI-u Ctrl+letter inside bracketed paste, fixes #3599 (#3623)
Co-authored-by: Georgi Chochev <georgi.chochev@siteground.com>
2026-04-24 13:30:49 +02:00
Mario Zechner 8234ebf9ee feat(coding-agent,tui): add stacked autocomplete providers closes #2983 2026-04-22 15:44:08 +02:00
Mario Zechner 6b55d6859d fix(tui): restore shifted xterm input
closes #3436
2026-04-20 15:36:10 +02:00
Sviatoslav Abakumov 4dda448a3f fix(tui): preserve column of cursor before it entered a paste marker (#3092) 2026-04-13 11:03:18 +02:00
Mario Zechner a1e107897d fix(tui): await async slash command completions closes #2719 2026-03-31 14:41:50 +02:00
Mario Zechner 0406b41a46 fix(tui): keep @ autocomplete responsive in large trees closes #1278 2026-03-26 15:43:51 +01:00
Mario Zechner 21950c5ba4 fix(tui): stop chaining slash arg autocomplete after Tab closes #2577 2026-03-24 23:52:48 +01:00
Mario Zechner e3fee7a511 fix(keybindings): migrate to namespaced ids closes #2391 2026-03-20 01:55:30 +01:00
Markus Ylisiurunen c9a3d14aa5 feat(tui): make select list column sizing configurable (#2154)
* feat(tui): make select list layout configurable

* feat(tui): tune select list column sizing

* test(tui): fix select list alignment assertions
2026-03-14 15:50:00 +01:00
Mario Zechner ad32089f0c fix(tui): preserve literal paste content closes #2064 2026-03-14 04:34:40 +01:00
xu0o0 bd2c3ab67e feat(tui): treat paste markers as atomic segments in editor (#2111)
* feat(tui): treat paste markers as atomic segments in editor

Paste markers like `[paste #1 +123 lines]` are now treated as single
atomic units for cursor movement, word navigation, deletion, and
wrapping. Only markers with valid paste IDs (present in the editor's
pastes Map) are treated atomically.

* fix(tui): word-wrap oversized atomic segments in editor
2026-03-13 17:42:59 +01:00
xu0o0 adce496f63 fix(tui): handle narrow terminal width in editor scroll indicator (#2103) 2026-03-13 17:41:14 +01:00
xu0o0 b6b7fafddb fix(tui): normalize tabs in editor setText and input paths (#2027) 2026-03-12 23:48:15 +00:00
xu0o0 48e4bd94ef fix(tui): wordWrapLine overflow with wide chars at wrap boundary (#2082) 2026-03-12 23:46:37 +00:00
Benjamin Rapaport 6937d2129e fix(tui): chain slash arg autocomplete after Tab completion
fixes #1437
2026-03-07 23:19:26 +01:00
Aliou Diallo e3decbcdd6 fix(tui): autocomplete highlight follows first prefix match as user types (#1931) 2026-03-07 19:03:42 +01:00
Mario Zechner 9bcf06c056 fix(tui): add Kitty CSI-u printable decoding to Input component, closes #1857 2026-03-06 00:33:58 +01:00
Mario Zechner 689e7b4ac2 fix(tui): make single-line paste atomic to avoid @ autocomplete lag
closes #1812
2026-03-04 18:25:37 +01:00
Mario Zechner 49749407fa fix(tui): ignore unsupported Kitty CSI-u modifiers closes #1807 2026-03-04 18:14:29 +01:00
Sviatoslav Abakumov 4c2d78f6cb Add the kill ring and undo features to the Input component (#1373)
* feat(tui): extract KillRing and UndoStack, add to Input

Extract kill ring and undo logic from Editor into reusable classes:

- KillRing: ring buffer with accumulation for consecutive kills
- UndoStack<S>: generic stack with clone-on-push semantics

Refactor Editor to use both classes. Add kill ring (kill/yank/
yank-pop), undo with coalescing, and deleteWordForward to Input.

* feat(tui): extract handleBackspace() and handleForwardDelete()
2026-02-07 15:47:27 +01:00
Aliou Diallo 9920d899b5 fix(tui): allow slash command menu on first line with existing text 2026-02-04 14:02:38 +01:00
Mario Zechner 20d704fee1 fix(tui): restore legacy newline handling 2026-02-03 01:36:46 +01:00
Mario Zechner c64e228b76 fix(tui): honor keybindings for submit fallback 2026-02-03 01:10:06 +01:00
Sviatoslav Abakumov d075291b08 feat(tui): add sticky column for vertical cursor navigation (#1120)
When moving up/down through lines of varying lengths, the editor now
remembers the original column position and restores it when reaching a
line long enough to accommodate it.

Example: cursor at column 10, move up to a shorter line (cursor clamps
to end), move up again to a longer line - cursor returns to column 10.

Implementation:

- Add preferredVisualCol instance property (nullable)
- Set it when moving to a shorter line during vertical navigation
- Clear it when arriving at a line that fits the preferred column
- Clear it on any horizontal movement or editing via setCursorCol()
- Detect line rewrap by checking if cursor is in middle of line
- When pressing right at end of prompt, set preferredVisualCol so
  subsequent up/down navigation uses that column position
2026-01-31 22:52:47 +01:00
4h9fbZ ab37d661af feat(tui): jump to line start/end when pressing up/down at boundaries (#1050)
When cursor is on the first visual line and up is pressed, jump to
start of line instead of doing nothing. When cursor is on the last
visual line and down is pressed, jump to end of line instead of doing
nothing. This matches standard behavior in most native text inputs.
2026-01-30 02:42:24 +01:00
Sviatoslav Abakumov c5d16fe456 feat(tui): add character jump navigation (Ctrl+], Ctrl+Alt+]) (#1074)
Add Bash/Readline-style character search:

- Ctrl+] enters forward jump mode, awaits next character, jumps to it
- Ctrl+Alt+] does the same but searches backward
- Multi-line search
- Case-sensitive matching
- Pressing the hotkey again cancels; control chars cancel and fall
  through
2026-01-30 01:42:14 +01:00
Colin Mason b212314f45 feat: add autocompleteMaxVisible setting for configurable dropdown height 2026-01-29 03:16:52 +01:00
Sviatoslav Abakumov b54d689ec1 A couple of autocomplete improvements (#1024)
* fix(tui): keep file suggestions open when typing in Tab-triggered mode

Previously, pressing Tab on an empty prompt or after a space would show
file suggestions, but typing a letter would dismiss them because the
text didn't look like a path pattern. Now the editor tracks whether
autocomplete was triggered via Tab (force mode) or naturally (regular
mode), and uses the appropriate suggestion method when updating.

* fix(tui): hide autocomplete when backspacing slash command to empty

Previously, typing / showed slash command suggestions, but pressing
Backspace to delete it showed file suggestions instead of hiding all
suggestions.
2026-01-29 02:48:09 +01:00
Sviatoslav Abakumov d57a26c88b fix(tui): remove backslash input buffering (#1037)
Instead of buffering `\` and waiting for the next key, let it be
inserted immediately. On Enter, check if preceded by `\` and treat as
newline.

Removed backslash handling from the Input component entirely.
2026-01-29 02:47:15 +01:00
Sviatoslav Abakumov 1224b31135 feat(tui): auto-apply single suggestion in force file autocomplete (#993)
When Tab triggers file autocomplete and there's exactly one matching
suggestion, apply it immediately without showing the menu. This makes
path completion faster by eliminating the extra Tab press to confirm.
2026-01-28 02:12:18 +01:00
Sviatoslav Abakumov beb1455cab fix(tui): move lastAction handling out of setTextInternal()
The caller is responsible for doing that.
2026-01-25 17:50:55 +04:00
Sviatoslav Abakumov 609095b0b6 fix(tui): refactor the multi-line insertion handling 2026-01-25 17:50:50 +04:00
Sviatoslav Abakumov 7d2d170c1b fix(tui): handle multi-line text in insertTextAtCursor()
Add insertTextAtCursorInternal() to properly handle newlines by splitting
lines at the cursor position.

- Normalize line endings (CRLF/CR to LF)
- Handle single-line and multi-line insertion
- Position cursor at end of inserted text
- Call onChange only once at the end

Refactor handlePaste() to use insertTextAtCursorInternal() for
multi-line pastes, while retaining character-by-character insertion for
single-line pastes to preserve autocomplete triggering.
2026-01-25 17:28:54 +04:00
Sviatoslav Abakumov b5ab90f837 fix(tui): reserve 1 column for cursor in word wrap width 2026-01-24 17:41:10 +04:00
Sviatoslav Abakumov 9090268b7d fix(tui): rewrite word wrap as single-pass with backtracking 2026-01-23 22:31:41 +04:00
Mario Zechner f42deae13e fix(tui): gate slash menu to empty input 2026-01-22 23:12:33 +01:00
Sviatoslav Abakumov 6bde679a5f fix(tui): use the non-null assertion operator instead of assert() 2026-01-19 00:18:47 +01:00
Sviatoslav Abakumov bacf334bc4 feat(tui): add undo support to Editor with the Ctrl+- hotkey
Undo snapshots are captured for all edit operations:

- Word insertion, backspace, forward delete
- Word/line deletion (Ctrl+W, Ctrl+U, Ctrl+K, Alt+D)
- Yank/yank-pop, paste, autocomplete completion
- Cursor movement starts a new undo unit
- setText() pushes snapshot when content changes

Additionally, history browsing captures the undo state on first entry.
2026-01-19 00:18:47 +01:00
Mario Zechner 18d9d9d704 fix(tui): document kill ring and reset history 2026-01-17 21:12:48 +01:00