Skip to content

Commit 453517a

Browse files
douzebisepage
andauthored
Update clap_complete/src/env/shells.rs
Co-authored-by: Ed Page <eopage@gmail.com>
1 parent 7ab2259 commit 453517a

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

clap_complete/src/env/shells.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ _clap_complete_NAME() {
3939
fi
4040
local words=("${COMP_WORDS[@]}")
4141
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.
4947
local _i _cword=$COMP_CWORD
5048
words=()
5149
for (( _i = 0; _i < ${#COMP_WORDS[@]}; _i++ )); do

0 commit comments

Comments
 (0)