Skip to content

Commit

Permalink
fix(qdbus): remove cur and all the rest arguments
Browse files Browse the repository at this point in the history
The current codebase removes the last word when `cur` has non-empty
value.  This piece of code was originally introduced in commit
1d74adc.  The original code before this commit tried to remove the
suffix ` $cur` from ${COMP_WORDS[*]}.  This means that the last word
was assumed in the commit to be the current word, which is not the
case when the user attempts the completion in the middle of the
command line.  In this patch, only the words before the current word
is used, (i.e., the current word (at the index of `cword`) and all the
rest words are removed).
  • Loading branch information
akinomyoga committed Sep 25, 2023
1 parent 556b732 commit 531b751
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions completions/qdbus
Expand Up @@ -6,8 +6,7 @@ _comp_cmd_qdbus()
_comp_initialize -- "$@" || return

_comp_compgen_split -- "$(
[[ $cur ]] && unset -v "words[$((${#words[@]} - 1))]"
command "${words[@]}" 2>/dev/null | command sed 's/(.*)//'
command "${words[@]::cword}" 2>/dev/null | command sed 's/(.*)//'
)"
} &&
complete -F _comp_cmd_qdbus qdbus dcop
Expand Down

0 comments on commit 531b751

Please sign in to comment.