mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
complete: print completions without the implied -c
switch
This switch is no longer necessary when only one command is given. Internally completions are stored separately for each command, so we only every print one command name per "complete" line anyway.
This commit is contained in:
parent
f20e8e5860
commit
eca2a8ba55
3 changed files with 25 additions and 14 deletions
|
@ -32,7 +32,7 @@ Description
|
|||
For an introduction to writing your own completions, see :ref:`Writing your own completions <completion-own>` in
|
||||
the fish manual.
|
||||
|
||||
- ``-c COMMAND`` or ``--command COMMAND`` specifies that ``COMMAND`` is the name of the command. If there is no ``-c``, one non-option argument will be used as the command.
|
||||
- ``-c COMMAND`` or ``--command COMMAND`` specifies that ``COMMAND`` is the name of the command. If there is no ``-c`` or ``-p``, one non-option argument will be used as the command.
|
||||
|
||||
- ``-p COMMAND`` or ``--path COMMAND`` specifies that ``COMMAND`` is the absolute path of the command (optionally containing wildcards).
|
||||
|
||||
|
|
|
@ -1756,7 +1756,12 @@ static wcstring completion2string(const complete_entry_opt_t &o, const wcstring
|
|||
append_switch(out, L"requires-param");
|
||||
}
|
||||
|
||||
append_switch(out, is_path ? L'p' : L'c', cmd);
|
||||
if (is_path)
|
||||
append_switch(out, L'p', cmd);
|
||||
else {
|
||||
out.append(L" ");
|
||||
out.append(escape_string(cmd, ESCAPE_ALL));
|
||||
}
|
||||
|
||||
switch (o.type) {
|
||||
case option_type_args_only: {
|
||||
|
@ -1806,8 +1811,8 @@ wcstring complete_print(const wcstring &cmd) {
|
|||
const wcstring &src = entry.first;
|
||||
if (!cmd.empty() && src != cmd) continue;
|
||||
for (const wcstring &target : entry.second) {
|
||||
out.append(L"complete");
|
||||
append_switch(out, L'c', src);
|
||||
out.append(L"complete ");
|
||||
out.append(escape_string(src, ESCAPE_ALL));
|
||||
append_switch(out, L"wraps", target);
|
||||
out.append(L"\n");
|
||||
}
|
||||
|
|
|
@ -50,14 +50,14 @@ complete -c 'complete test beta2' -r -d 'desc \' desc2 [' -a 'foo bar'
|
|||
complete -c complete_test_beta2 -x -n false -A -o test
|
||||
complete
|
||||
|
||||
# CHECK: complete --no-files -c complete_test_alpha1 -a '(commandline)'
|
||||
# CHECK: complete --no-files -c complete_test_alpha2
|
||||
# CHECK: complete --no-files -c complete_test_alpha3
|
||||
# CHECK: complete --force-files -c t -l fileoption
|
||||
# CHECK: complete --no-files -c t -a '(t)'
|
||||
# CHECK: complete --no-files complete_test_alpha1 -a '(commandline)'
|
||||
# CHECK: complete --no-files complete_test_alpha2
|
||||
# CHECK: complete --no-files complete_test_alpha3
|
||||
# CHECK: complete --force-files t -l fileoption
|
||||
# CHECK: complete --no-files t -a '(t)'
|
||||
# CHECK: complete -p '/complete test/beta1' -s Z -d 'desc, desc'
|
||||
# CHECK: complete --requires-param -c 'complete test beta2' -d desc\ \'\ desc2\ \[ -a 'foo bar'
|
||||
# CHECK: complete --exclusive -c complete_test_beta2 -o test -n false
|
||||
# CHECK: complete --requires-param 'complete test beta2' -d desc\ \'\ desc2\ \[ -a 'foo bar'
|
||||
# CHECK: complete --exclusive complete_test_beta2 -o test -n false
|
||||
# CHECK: complete {{.*}}
|
||||
# CHECK: complete {{.*}}
|
||||
# CHECK: complete {{.*}}
|
||||
|
@ -357,13 +357,13 @@ end
|
|||
# This should only list the completions for `banana`
|
||||
complete -c banana -a '1 2 3'
|
||||
complete -c banana
|
||||
#CHECK: complete -c banana -a '1 2 3'
|
||||
#CHECK: complete banana -a '1 2 3'
|
||||
|
||||
# "-c" is optional
|
||||
complete banana -a bar
|
||||
complete banana
|
||||
#CHECK: complete -c banana -a bar
|
||||
#CHECK: complete -c banana -a '1 2 3'
|
||||
#CHECK: complete banana -a bar
|
||||
#CHECK: complete banana -a '1 2 3'
|
||||
|
||||
# "-a" ain't
|
||||
complete banana bar
|
||||
|
@ -374,3 +374,9 @@ complete banana bar
|
|||
#CHECKERR: ^
|
||||
#CHECKERR:
|
||||
#CHECKERR: (Type 'help complete' for related documentation)
|
||||
|
||||
# Multiple commands can be specified, in that case "-c" (or "-p") is mandatory.
|
||||
complete -c kapstachelbeere -c physalis -a arg
|
||||
complete -c kapstachelbeere -c physalis
|
||||
# CHECK: complete kapstachelbeere -a arg
|
||||
# CHECK: complete physalis -a arg
|
||||
|
|
Loading…
Reference in a new issue