Improve _get_comp_words_by_ref()
Empty $cur with cmd = " | a " (| = cursor position) (Alioth #313102)
This commit is contained in:
parent
2f37a38b79
commit
6e7359f69c
5
CHANGES
5
CHANGES
@ -40,8 +40,9 @@ bash-completion (2.x)
|
|||||||
[ Freddy Vulto ]
|
[ Freddy Vulto ]
|
||||||
* Improve __reassemble_comp_words_by_ref() to not create words of
|
* Improve __reassemble_comp_words_by_ref() to not create words of
|
||||||
characters-to-exclude (Alioth: #313057)
|
characters-to-exclude (Alioth: #313057)
|
||||||
* Improve _get_comp_words_by_ref() with cursor at position 0. Patch by
|
* Fix _get_comp_words_by_ref() with cursor at position 0. Patch by Igor
|
||||||
Igor Murzov (Debian: #559953)
|
Murzov (Debian: #559953).
|
||||||
|
* Fix _get_comp_words_by_ref() with spaces before cursor (Alioth #313102).
|
||||||
|
|
||||||
[ Mattias Ulbrich ]
|
[ Mattias Ulbrich ]
|
||||||
* Make java class completion suggest packages.
|
* Make java class completion suggest packages.
|
||||||
|
@ -348,9 +348,9 @@ __get_cword_at_cursor_by_ref()
|
|||||||
local cword words=()
|
local cword words=()
|
||||||
__reassemble_comp_words_by_ref "$1" words cword
|
__reassemble_comp_words_by_ref "$1" words cword
|
||||||
|
|
||||||
local i cur cur2
|
local i cur cur2 index=$COMP_POINT lead=${COMP_LINE:0:$COMP_POINT}
|
||||||
local index=$COMP_POINT
|
# Cursor not at position 0 and not leaded by just space(s)?
|
||||||
if (( index )); then
|
if [[ $index -gt 0 && ( $lead && ${lead//[[:space:]]} ) ]]; then
|
||||||
cur=$COMP_LINE
|
cur=$COMP_LINE
|
||||||
for (( i = 0; i <= cword; ++i )); do
|
for (( i = 0; i <= cword; ++i )); do
|
||||||
while [[
|
while [[
|
||||||
@ -374,23 +374,14 @@ __get_cword_at_cursor_by_ref()
|
|||||||
index=$(( index - old_size + new_size ))
|
index=$(( index - old_size + new_size ))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
# Clear $cur if just space(s)
|
||||||
|
[[ $cur && ! ${cur//[[:space:]]} ]] && cur=
|
||||||
|
# Zero $index if negative
|
||||||
|
[[ $index -lt 0 ]] && index=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $index -lt 0 ]]; then
|
local "$2" "$3" "$4" && _upvars -a${#words[@]} $2 "${words[@]}" \
|
||||||
# This happens when completing: "command | arg" (| is where
|
-v $3 "$cword" -v $4 "${cur:0:$index}"
|
||||||
# TAB is hit)
|
|
||||||
index=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${words[cword]:0:${#cur}}" != "$cur" ]]; then
|
|
||||||
# We messed up. At least return the whole word so things keep working
|
|
||||||
cur2=${words[cword]}
|
|
||||||
else
|
|
||||||
cur2=${cur:0:$index}
|
|
||||||
fi
|
|
||||||
|
|
||||||
local "$2" "$3" "$4" &&
|
|
||||||
_upvars -a${#words[@]} $2 "${words[@]}" -v $3 "$cword" -v $4 "$cur2"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user