mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-27 19:53:36 +08:00
45e7c709f4
Detect recursive calls to builtin complete and the internal completion in
the same place.
In 0a0149cc2
(Prevent infinite recursion when completion wraps variable assignment)
we don't print an error when completing certain aliases like:
alias vim "A=B vim"
But we also gave no completions.
We could make this case work, but I think that trying to salvage situations
like this one is way too complex. Instead, let the user know by printing an
error. Not sure if the style of the error fits.
We could add some heuristic to alias to not add --wraps in some cyclic cases.
36 lines
1.1 KiB
Fish
36 lines
1.1 KiB
Fish
#RUN: %fish %s
|
|
# Validate some things about command wrapping.
|
|
|
|
set -g LANG C # For predictable error messages.
|
|
|
|
# This tests that we do not trigger a combinatorial explosion - see #5638.
|
|
# Ensure it completes successfully.
|
|
complete -c testcommand --wraps "testcommand x "
|
|
complete -c testcommand --wraps "testcommand y "
|
|
complete -c testcommand --no-files -a normal
|
|
complete -C'testcommand '
|
|
# CHECK: normal
|
|
|
|
# We get the same completion twice. TODO: fix this.
|
|
# CHECK: normal
|
|
|
|
|
|
# This tests that a call to complete from within a completion doesn't trigger
|
|
# wrap chain explosion - #5638 again.
|
|
function testcommand2_complete
|
|
set -l tokens (commandline -opc) (commandline -ct)
|
|
set -e tokens[1]
|
|
echo $tokens 1>&2
|
|
end
|
|
|
|
complete -c testcommand2 -x -a "(testcommand2_complete)"
|
|
complete -c testcommand2 --wraps "testcommand2 from_wraps "
|
|
complete -C'testcommand2 explicit '
|
|
# CHECKERR: explicit
|
|
# CHECKERR: from_wraps explicit
|
|
|
|
|
|
complete -c recvar --wraps 'A=B recvar'
|
|
complete -C 'recvar '
|
|
# CHECKERR: <E> fish: completion reached maximum recursion depth, possible cycle?
|