Skip to content

Commit 0d55af2

Browse files
committed
zsh: skip repeat Python runs in the same completion run
1 parent cc47d2c commit 0d55af2

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

argcomplete/bash_completion.d/_python-argcomplete

+6
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ __python_argcomplete_which() {
124124
_python_argcomplete_global() {
125125

126126
if [[ -n "${ZSH_VERSION-}" ]]; then
127+
if [[ "${_matcher_num-}" -gt 1 ]]; then
128+
# Return early if the completer is called multiple times in the same completion run.
129+
# Currently the only known occurrence of this is in zsh when a matcher-list zstyle is declared.
130+
# When this happens, _matcher_num is incremented past 1.
131+
return
132+
fi
127133
# Store result of a regex match in the
128134
# BASH_REMATCH variable rather than MATCH
129135
setopt local_options BASH_REMATCH

argcomplete/shell_integration.py

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
local IFS=$'\013'
3535
local script="%(argcomplete_script)s"
3636
if [[ -n "${ZSH_VERSION-}" ]]; then
37+
if [[ "${_matcher_num-}" -gt 1 ]]; then
38+
# Return early if the completer is called multiple times in the same completion run.
39+
# Currently the only known occurrence of this is in zsh when a matcher-list zstyle is declared.
40+
# When this happens, _matcher_num is incremented past 1.
41+
return
42+
fi
3743
local completions
3844
completions=($(IFS="$IFS" \
3945
COMP_LINE="$BUFFER" \

0 commit comments

Comments
 (0)