Commit 75d9bdf
authored
0.17 phase 5 PR D: history lane reservation + path escape (#145)
* feat(suggest): reserve 2 history rows for exact/prefix matches
When a SpecArg context saturates max_results with normal candidates, the
post-rank history fuzzy-fill flow had no room to add anything — its
remaining = max_history_results.min(max_results - results.len()) clamped
to zero. High-confidence (prefix/exact) history rows vanished from the
popup whenever it filled up.
rank_with_history now reserves up to 2 slots for prefix-matching history
BEFORE ranking candidates. The cap is reduced upstream so the popup
never grows past max_results. Flag and redirect contexts skip the lane
entirely (flags don't prefix-match command lines; redirects want
filenames).
* feat(handler): shell-escape accepted paths; quote-context aware
Filesystem suggestions (FilePath/Directory kinds) are now escaped before
the byte buffer is sent to the shell. Unquoted context backslashes the
full word-splitting/expansion metacharacter set; single quotes only
need the close-reopen dance for embedded apostrophes; double quotes
escape the four-character set (", \\, $, backtick).
The escape is applied once inside accept_suggestion_locked and the
escaped replacement is returned so the chaining caller writes the SAME
text into the predicted buffer. Without that, the engine's next
context read would see the raw display text while the shell sees the
escaped form — the next completion would resolve the wrong directory.
* fix(review-loop): iteration 1 — address 12 review findings
- gc-pty/handler.rs: preserve leading-tilde so tilde expansion survives accept;
compute accept/chaining delete-count from the raw on-screen word span (fixes
under-deletion when the buffer holds backslash escapes / open quotes); replace
AcceptLockedOutput 5-tuple with named AcceptLocked struct using distinct
CursorPos/ScreenSize newtypes; refresh doc comment; add escaping, empty-input,
glob, and chaining/quote-context regression tests
- gc-suggest/engine.rs: clamp reserved_history to max_history_results; document the
deliberate flag-context history suppression; add reservation-boundary tests
(no-prefix-match, single, three-clamped-to-two, empty-history-with-allowed-lane)
* fix(review-loop): iteration 2 — fix quoted-accept regression + close test gaps
- gc-pty/handler.rs: preserve the user's opening quote on accept inside an open
single/double quote (prior iteration's raw-span delete count included the quote
but the quoted escape arms emit bare text expecting it to survive, silently
word-splitting the path); add current_word_delete_start to start the delete span
after the unmatched opening quote (incl. mid-word quote); apply same to chaining
predicted buffer; correct the existing test that encoded the regression; drop
() from current_word_raw_start boundary set to match the tokenizer; construct
CursorPos/ScreenSize at the read site; add closing-quote, multibyte, operator,
paren, and trailing-backslash tests
- gc-suggest/engine.rs: add load-bearing test for the reserved_history .min clamp
(max_history_results=1 with two prefix matches)
* test(review-loop): iteration 3 — guard quoted directory chaining
- gc-pty/handler.rs: add exact-assertion regression tests for accept_with_chaining
inside an open single/double quote (predicted command buffer must preserve the
opening quote, leave the space literal, insert no backslash). Code was already
correct; these close the last coverage gap on the chaining predict path.1 parent 5de74d0 commit 75d9bdf
2 files changed
Lines changed: 1290 additions & 67 deletions
0 commit comments