Simplify sub-command loop logic

If the cursor is on the sub-command, just offer sub-command
completions and be done with it. It was way over complicated.
This commit is contained in:
Vladimir Zhelezov 2020-12-13 07:43:29 +01:00
parent f5d2a6bcc3
commit 046421e712
2 changed files with 6 additions and 18 deletions

View File

@ -36,16 +36,10 @@ _hledger_completion_function() {
# $subcommand == bal --> balance, balancesheet, balancesheetequity, etc.
# Do not ignore them!
if ((i == cword)); then
local subcommandMatches
subcommandMatches=$(grep -c "^$subcommand" <<< "$_hledger_complist_commands")
if ((subcommandMatches > 1)); then
subcommand=
break
else
_hledger_compreply "$subcommand"
compopt +o filenames
_hledger_compreply "$(_hledger_compgen "$_hledger_complist_commands")"
return 0
fi
fi
break
done

View File

@ -36,16 +36,10 @@ _hledger_completion_function() {
# $subcommand == bal --> balance, balancesheet, balancesheetequity, etc.
# Do not ignore them!
if ((i == cword)); then
local subcommandMatches
subcommandMatches=$(grep -c "^$subcommand" <<< "$_hledger_complist_commands")
if ((subcommandMatches > 1)); then
subcommand=
break
else
_hledger_compreply "$subcommand"
compopt +o filenames
_hledger_compreply "$(_hledger_compgen "$_hledger_complist_commands")"
return 0
fi
fi
break
done