Use compopt -o nospace only for a query prefix

Similarly to long options treatment, suspend space only when
completing what looks like a query or account prefix i.e. something
ending with a colon (:).
This commit is contained in:
Vladimir Zhelezov 2020-12-14 04:50:28 +01:00
parent 797301c3dc
commit 34dbe3b3a8
2 changed files with 10 additions and 4 deletions

View File

@ -97,8 +97,6 @@ _hledger_completion_function() {
esac
# Offer query filters and accounts for the rest
# Do not sort. Keep accounts and query filters grouped separately
compopt -o nosort -o nospace
_hledger_compreply "$(_hledger_compgen "$_hledger_complist_query_filters")"
if [[ -z $cur ]]; then
_hledger_compreply_append "$(
@ -110,6 +108,11 @@ _hledger_completion_function() {
)"
fi
# Suspend space on completion of query prefix
# Do not sort, keep accounts and query filters grouped separately
[[ ${COMPREPLY[0]} == *: ]] && compopt -o nospace
compopt -o nosort
return 0
}

View File

@ -97,8 +97,6 @@ _hledger_completion_function() {
esac
# Offer query filters and accounts for the rest
# Do not sort. Keep accounts and query filters grouped separately
compopt -o nosort -o nospace
_hledger_compreply "$(_hledger_compgen "$_hledger_complist_query_filters")"
if [[ -z $cur ]]; then
_hledger_compreply_append "$(
@ -110,6 +108,11 @@ _hledger_completion_function() {
)"
fi
# Suspend space on completion of query prefix
# Do not sort, keep accounts and query filters grouped separately
[[ ${COMPREPLY[0]} == *: ]] && compopt -o nospace
compopt -o nosort
return 0
}