__get_cword: avoid $index < 0 (Alioth: #315107)

Modified-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
master
Ondrej Oprala 2015-07-08 09:40:14 +02:00 committed by Ville Skyttä
parent f68589fde4
commit fa1ad7dff9
6 changed files with 18 additions and 4 deletions

View File

@ -320,8 +320,8 @@ __get_cword_at_cursor_by_ref()
]]; do
# Strip first character
cur="${cur:1}"
# Decrease cursor position
((index--))
# Decrease cursor position, staying >= 0
[[ $index -gt 0 ]] && ((index--))
done
# Does found word match cword?
@ -450,8 +450,8 @@ _get_cword()
]]; do
# Strip first character
cur="${cur:1}"
# Decrease cursor position
((index--))
# Decrease cursor position, staying >= 0
[[ $index -gt 0 ]] && ((index--))
done
# Does found word matches cword?

0
test/fixtures/_get_cword/sea vendored Normal file
View File

0
test/fixtures/_get_cword/seb vendored Normal file
View File

0
test/fixtures/_get_cword/sec vendored Normal file
View File

0
test/fixtures/_get_cword/ääää§ vendored Normal file
View File

View File

@ -249,4 +249,18 @@ expect {
sync_after_int
set test "index shouldn't drop below 0"
set dir $::srcdir/fixtures/_get_cword
set cmd "scp"
send "$cmd ääää§ se\t\r\n"
expect {
-re "index: substring expression < 0" { fail "$test" }
-re /@ { pass "$test" }
default { unresolved "$test" }
}
sync_after_int
teardown