Add menu completion for --position=anywhere abbrs in non-command position#12764
Add menu completion for --position=anywhere abbrs in non-command position#12764g0t4 wants to merge 3 commits intofish-shell:masterfish-shell/fish-shell:masterfrom g0t4:feature-complete-abbr-in-non-command-positiong0t4/fish-shell:feature-complete-abbr-in-non-command-positionCopy head branch name to clipboard
Conversation
Abbreviations with `--position anywhere` now appear in the completion menu when tabbing in argument position (e.g. `cat foo.log pg<TAB>` shows pgr, pgrv, pjq, etc.), not just in command position. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t what can complete it (position=anywhere)
|
#12630 is going to outlaw AI-authored commits, so this would be against policy. |
Make abbreviations with `--position anywhere` appear in the completion menu when tabbing in argument position (e.g. `cat foo.log pg<TAB>` shows pgr, pgrv, pjq, etc.), not just in command position. Lift "do_file" into an enum, so we don't have to check "is_redirection" twice, and can express more accurately the reason for not completing abbreviations after redirection. Co-authored-by: Johannes Altmanninger <aclopte@gmail.com> Closes #12764
|
Sorry I had missed this one. |
|
👍 I like the
Thanks for cleaning that up... this is a game changer for how I use abbrs! will do on squash next time |
|
Turns out AI slop always makes things worse, lol. Even if it's not just about the quality of the code, AI makes people think less before implementing anything. Fixing one thing while creating several more new bugs, or adding a new feature that breaks several existing features. |
Summary
Current tab completion behavior:
abbrs can only be completed in command position (non-regex abbrs)Desired behvaior: add completion for non-command position which would only apply to
abbrs with--position=anywhereExamples
right now if I don't know the exact abbr in non-command position, I can't use the abbr... but when I am learning abbrs, if I can tab complete to see choices, that helps me learn
Changes
BTW, existing abbr completion works for command position only.
I added a boolean parameter
is_command_positiontocomplete_abbr(&mut self, cmd: WString, is_command_position: bool)is_command_position = falsetriggers existing command position completion.is_command_position = truetriggers the new, non-command position completion which means only abbrs that have--position=anywhereIn all cases, regex based abbrs are excluded, preserving existing behavior.
I added three tests using my
pgrexample, see ./tests/checks/complete.fishTODOs:
Fixes issue #<issue-number>