Skip to content

Commit 2b53f6a

Browse files
committed
fix(expansion): no false positive expansions after ((
1 parent f027565 commit 2b53f6a

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

zsh-abbr.zsh

+8-10
Original file line numberDiff line numberDiff line change
@@ -933,28 +933,26 @@ _zsh_abbr_init() {
933933
# -------
934934

935935
_zsh_abbr_expand_widget() {
936-
local current_word
937936
local expansion
937+
local word
938+
local words
938939
local word_count
939940

940-
current_word=$LBUFFER
941-
word_count=${(w)#LBUFFER}
941+
words=(${(z)LBUFFER})
942+
word=$words[-1]
943+
word_count=${#words}
942944

943945
if [[ $word_count == 1 ]]; then
944-
expansion=$(_zsh_abbr_cmd_expansion "$current_word")
946+
expansion=$(_zsh_abbr_cmd_expansion "$word")
945947
fi
946948

947949
if ! [[ -n "$expansion" ]]; then
948-
if [[ $word_count > 1 ]]; then
949-
current_word=${${(z)LBUFFER}: -1}
950-
fi
951-
952-
expansion=$(_zsh_abbr_global_expansion "$current_word")
950+
expansion=$(_zsh_abbr_global_expansion "$word")
953951
fi
954952

955953
if [[ -n "$expansion" ]]; then
956954
local preceding_lbuffer
957-
preceding_lbuffer="${LBUFFER%%$current_word}"
955+
preceding_lbuffer="${LBUFFER%%$word}"
958956
LBUFFER="$preceding_lbuffer$expansion"
959957
fi
960958
}

0 commit comments

Comments
 (0)