Repository navigation
__fish_complete_list adds --option= name for each item #11508
Copy link
Copy link
Closed
Labels
regressionSomething that used to work, but was broken, especially between releasesSomething that used to work, but was broken, especially between releases
Milestone
Description
Activity
- addedregressionSomething that used to work, but was broken, especially between releasesSomething that used to work, but was broken, especially between releases
on May 18, 2025 - Hmm this is a regression from f9febba (Fix replacing completions with a -foo prefix, 2024-12-14) which fixed replacing completions like "usermod --groups=oot<TAB>". I guess we can adjust the uses of "(commandline -t)" that look like "--option=VALUE". I wonder whether we should support the case where VALUE contains an equal sign, by adding extra code to each call to "__fish_complete_list" (diff below). OTOH, __fish_append does «string replace -r -- '--.*=' ''» since 11273a7 (Various corrections for advanced tab completions. Should make the --export, 2006-01-14). Though that doesnt' support short options. diff --git a/share/completions/usermod.fish b/share/completions/usermod.fish index f457e9b6a2..b0cce3a8c2 100644 --- a/share/completions/usermod.fish +++ b/share/completions/usermod.fish @@ -5,7 +5,7 @@ complete -c usermod -s e -l expiredate -d "Date (YYYY-MM-DD) on which the user account will be disabled" -x complete -c usermod -s f -l inactive -d "Number of days after a password expires until the account is locked" -xa "(seq 0 365)" complete -c usermod -s g -l gid -d "Group name or number of the user's new initial login group" -xa "(__fish_complete_groups)" -complete -c usermod -s G -l groups -d "List of groups which the user is also a member of" -xa "(__fish_complete_list , __fish_complete_groups)" +complete -c usermod -s G -l groups -d "List of groups which the user is also a member of" -xa "(__fish_stripprefix='^(--groups=|-\w*G)' __fish_complete_list , __fish_complete_groups)" complete -c usermod -s l -l login -d "Change user's name" -x complete -c usermod -s L -l lock -d "Lock user's password" -f complete -c usermod -s m -l move-home -d "Move the content of the user's home directory to the new location" -f diff --git a/share/functions/__fish_complete_list.fish b/share/functions/__fish_complete_list.fish index 2d55c535e4..758489572f 100644 --- a/share/functions/__fish_complete_list.fish +++ b/share/functions/__fish_complete_list.fish @@ -14,7 +14,9 @@ set -q prefix[1] or set -l prefix "" set -l pat "$(commandline -t)" - #set -l pat $argv[5] + if set -q __fish_stripprefix[1] + set pat "$(string replace -r -- "$__fish_stripprefix" "" $pat)" + end switch $pat case "*$div*" for i in (echo $pat | sed "s/^\(.\+$div\)$iprefix.*\$/\1/")$iprefix(eval $cmd) diff --git a/tests/checks/complete.fish b/tests/checks/complete.fish index e8d904d7f0..6a52dc3c03 100644 --- a/tests/checks/complete.fish +++ b/tests/checks/complete.fish @@ -635,3 +635,15 @@ abbr cat cat complete -C ca | string match -r '^cat(?:\t.*)?$' # CHECK: cat{{\t}}Abbreviation: cat + +complete complete-list -xa '(__fish_complete_list , "seq 2")' +complete -C "complete-list 1," +# CHECK: 1,1 +# CHECK: 1,2 +complete complete-list -s l -l number-list -xa '(__fish_stripprefix="^(--number-list=|\w*l)" __fish_complete_list , "seq 2")' +complete -C "complete-list --number-list=1," +# CHECK: --number-list=1,1 +# CHECK: --number-list=1,2 +complete -C "complete-list -abcl1," +# CHECK: -abcl1,1 +# CHECK: -abcl1,2
There is another regression. Maybe it is related to the change you mentioned, so I note this here. If you say this is completely different I can open a new issue.
With
__fish_complete_list, if a completion item's description contains a literal\nthen it is turned into a real newline and breaks the completion item. With older fish, the literal\nis preserved and shown in the description as expected.\n then it is turned into a real newline
fixed that one as well
- added a commit that references this issue
on Jun 21, 2025 - locked as resolved and limited conversation to collaborators
on Jun 22, 2026
Metadata
Metadata
Assignees
Labels
regressionSomething that used to work, but was broken, especially between releasesSomething that used to work, but was broken, especially between releases
fish version 4.0.1 on Fedora 42 in Gnome Terminal
I think there is a regression with the behavior of
__fish_complete_list, which occurs when the=sign is used after the long option. The--option=part is then repeated for each item completed.Example:
Type
usermod --groups=and complete one group. Then go back, add a,and complete another group. Now the commandline is likeusermod --groups=--groups=abrt,adm.I also checked with an old fish version 3.6.0 on Debian stable and there it works as expected.