You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clap_complete/src/env/shells.rs
+5-7Lines changed: 5 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -39,13 +39,11 @@ _clap_complete_NAME() {
39
39
fi
40
40
local words=("${COMP_WORDS[@]}")
41
41
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
42
-
# bash splits on COMP_WORDBREAKS characters (e.g. '=', ':') so
43
-
# '--option=value' becomes ["--option", "=", "value"] in COMP_WORDS,
44
-
# and $2 (the word-to-complete) only contains the fragment after the
45
-
# last break character. We can't use $2 directly; instead we reassemble
46
-
# the word list by dropping single-character COMP_WORDBREAKS tokens and
47
-
# adjusting the index. Approach adapted from _comp__reassemble_words in
48
-
# https://github.com/scop/bash-completion.
42
+
# Reassemble the argument list from the word list by dropping single-character `COMP_WORDBREAKS` tokens and adjusting the index.
43
+
# This is in place of using `$2` (the word-to-complete) because bash splits the arguments into words using `COMP_WORDBREAKS` characters (e.g. '=', ':') so
44
+
# `--option=value` becomes `["--option", "=", "value"]` in `COMP_WORDS`.
45
+
#
46
+
# Approach adapted from `_comp__reassemble_words` in https://github.com/scop/bash-completion.
49
47
local _i _cword=$COMP_CWORD
50
48
words=()
51
49
for (( _i = 0; _i < ${#COMP_WORDS[@]}; _i++ )); do
0 commit comments