From 1f18b9715f86440a194aed76c470e3f42e32be42 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 14 May 2026 15:11:48 +0800 Subject: [PATCH] Fix repeated tab causing repeated smartcase completion insertion Doing firefox --pro TAB TAB TAB results in firefox --profile --ProfileManager git-bisect points to 3546ffa3ef5 (reader handle_completions(): remove dead filtering code, 2026-01-02) but that regression has already been fixed by 85e76ba3561 (Fix option substr completions not being filtered out, 2026-04-16). However in between those two commits, the above case has also been broken by 2f6b1eaaf9c (reader handle_completions(): don't consider odd replacing completions for common prefix, 2026-01-02) The first TAB inserts "--profile ", including the trailing space. However it also shows the completion pager, which means that subsequent TABs will insert after the space. The trailing space does not make sense unless we navigate the pager. Remove it in all cases, to fix this smartcase scenario. Alternatively, we could start navigating the pager in this case (and keep the trailing space), but that's probably too inconsistent. --- CHANGELOG.rst | 1 + src/reader/reader.rs | 9 ++------- tests/checks/tmux-complete4.fish | 18 +++++++++++++++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f9eb3140b..2573dd7aa 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -13,6 +13,7 @@ Interactive improvements Regression fixes: ----------------- - (from 4.4) Vi mode ``x`` in :doc:`builtin read ` (:issue:`12724`). +- (from 4.3.3) Repeated tab would sometimes insert smartcase completions redundantly. fish 4.7.1 (released May 08, 2026) ================================== diff --git a/src/reader/reader.rs b/src/reader/reader.rs index 7fdc6fe32..d5c33094f 100644 --- a/src/reader/reader.rs +++ b/src/reader/reader.rs @@ -7091,7 +7091,6 @@ fn handle_completions(&mut self, token_range: Range, mut comp: Vec, mut comp: Vec, mut comp: Vec : -cq] - tab # CHECK: [prompt 0> : -cq somefile] # CHECK: [somefile1 somefile2] - tab # CHECK: [prompt 0> : -cq somefile1] # CHECK: [somefile1 somefile2] + +isolated-tmux send-keys C-u C-l 'true --pro' +tab +# CHECK: [prompt 0> true --profile] +# CHECK: [--profile --ProfileManager] +tab +# CHECK: [prompt 0> true --profile] +# CHECK: [--profile --ProfileManager] +isolated-tmux send-keys foo +tmux-sleep +isolated-tmux capture-pane -p | awk '/./ { print "[" $0 "]" }' +# CHECK: [prompt 0> true --profile foo]