Bugfix and remove unused code
Bug was: Account names with spaces were broken into single completion suggestions, not line by line.
This commit is contained in:
parent
90257a1729
commit
e491f34ddf
@ -23,9 +23,6 @@ hledgerCompletionFunction() {
|
|||||||
declare subcommand
|
declare subcommand
|
||||||
for subcommand in "${COMP_WORDS[@]}"; do
|
for subcommand in "${COMP_WORDS[@]}"; do
|
||||||
if grep -Fxqe "$subcommand" "$HLEDGER_COMPLETION_TEMPDIR/commands.txt"; then
|
if grep -Fxqe "$subcommand" "$HLEDGER_COMPLETION_TEMPDIR/commands.txt"; then
|
||||||
#declare -a options
|
|
||||||
#readarray -t options <(grep "^$wordToComplete" "$HLEDGER_COMPLETION_TEMPDIR/options-$subcommand.txt")
|
|
||||||
#COMPREPLY+=( "${options[@]}" )
|
|
||||||
COMPREPLY+=( $(grep -h "^$wordToComplete" -- "$HLEDGER_COMPLETION_TEMPDIR/options-$subcommand.txt") )
|
COMPREPLY+=( $(grep -h "^$wordToComplete" -- "$HLEDGER_COMPLETION_TEMPDIR/options-$subcommand.txt") )
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -68,8 +65,13 @@ hledgerCompletionFunction() {
|
|||||||
# the 'hledger accounts' call. Note that --rules-file - if present - must also
|
# the 'hledger accounts' call. Note that --rules-file - if present - must also
|
||||||
# be passed!
|
# be passed!
|
||||||
|
|
||||||
|
declare -a accounts
|
||||||
|
readarray -t accounts < <(hledger accounts --flat | grep "^$wordToComplete")
|
||||||
|
COMPREPLY+=( "${accounts[@]}" )
|
||||||
|
# Special characters (e.g. '-', ':') are allowed in account names.
|
||||||
|
# Account names with spaces must be still be quoted (e.g. '"Expens')
|
||||||
|
# for completion. Setting COMP_WORDBREAKS='' would not help here!
|
||||||
COMP_WORDBREAKS=' '
|
COMP_WORDBREAKS=' '
|
||||||
COMPREPLY+=( $(hledger accounts --flat | grep "^$wordToComplete") )
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user