mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 03:51:14 -03:00
__fish_complete_list: only unescape "$(commandline -t)"
Commit cd3da62d24 (fix(completion): unescape strings for __fish_complete_list,
2024-09-17) bravely addressed an issue that exists in a lot of completions.
It did so only for __fish_complete_list. Fair enough.
Unfortunately it unescaped more than just "$(commandline -t)".
This causes the problem described at
https://github.com/fish-shell/fish-shell/issues/11508#issuecomment-2889088934
where completion descriptions containing a backslash followed by "n" are
interpreted as newlines, breaking the completion parser. Fix that.
This commit is contained in:
@@ -19,12 +19,12 @@ where:
|
|||||||
end
|
end
|
||||||
switch $pat
|
switch $pat
|
||||||
case "*$div*"
|
case "*$div*"
|
||||||
for i in (echo $pat | sed "s/^\(.\+$div\)$iprefix.*\$/\1/")$iprefix(eval $cmd)
|
for i in (string unescape -- $pat | sed "s/^\(.\+$div\)$iprefix.*\$/\1/")$iprefix(eval $cmd)
|
||||||
string unescape -- $i
|
printf %s\n $i
|
||||||
end
|
end
|
||||||
case '*'
|
case '*'
|
||||||
for i in $prefix$iprefix(eval $cmd)
|
for i in $prefix$iprefix(eval $cmd)
|
||||||
string unescape -- $i
|
printf %s\n $i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -647,3 +647,10 @@ complete -C "complete-list --number-list=1,"
|
|||||||
complete -C "complete-list -abcl1,"
|
complete -C "complete-list -abcl1,"
|
||||||
# CHECK: -abcl1,1
|
# CHECK: -abcl1,1
|
||||||
# CHECK: -abcl1,2
|
# CHECK: -abcl1,2
|
||||||
|
|
||||||
|
function esc_in_description
|
||||||
|
echo completion\t'escaped \n newline'
|
||||||
|
end
|
||||||
|
complete complete-list -l desc -xa '(__fish_complete_list , esc_in_description)'
|
||||||
|
complete -C 'complete-list --desc '
|
||||||
|
# CHECK: completion{{\t}}escaped {{\\n}} newline
|
||||||
|
|||||||
Reference in New Issue
Block a user