mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-29 04:53:17 +02:00
fix(z): prevent stack overflow from recursive Tab binding on re-source
The ZLE widget added in #13710 saves the current Tab binding and delegates to it. If the plugin is sourced more than once, the saved binding points to the widget itself, causing infinite recursion and "maximum nested function level reached" errors on any Tab press. Guard against self-reference by only capturing the binding on first load and falling back to expand-or-complete if the saved value is our own widget. Fixes #13714 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
278ee100fc
commit
a4f13aec98
1 changed files with 9 additions and 2 deletions
|
|
@ -960,8 +960,15 @@ add-zsh-hook chpwd _zshz_chpwd
|
||||||
|
|
||||||
(( ${fpath[(ie)${0:A:h}]} <= ${#fpath} )) || fpath=( "${0:A:h}" "${fpath[@]}" )
|
(( ${fpath[(ie)${0:A:h}]} <= ${#fpath} )) || fpath=( "${0:A:h}" "${fpath[@]}" )
|
||||||
|
|
||||||
# Save the existing Tab binding
|
# Save the existing Tab binding (only on first load to avoid self-reference
|
||||||
ZSHZ[TAB_BINDING]="${$(bindkey -M main '^I')##* }"
|
# if the plugin is sourced more than once)
|
||||||
|
if [[ -z ${ZSHZ[TAB_BINDING]} ]] || \
|
||||||
|
[[ ${ZSHZ[TAB_BINDING]} == _zshz_zle_completion_widget ]]; then
|
||||||
|
ZSHZ[TAB_BINDING]="${$(bindkey -M main '^I')##* }"
|
||||||
|
# If we somehow captured our own widget (race condition), fall back to default
|
||||||
|
[[ ${ZSHZ[TAB_BINDING]} == _zshz_zle_completion_widget ]] && \
|
||||||
|
ZSHZ[TAB_BINDING]=expand-or-complete
|
||||||
|
fi
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# ZLE widget to fix spaces-as-wildcards completion
|
# ZLE widget to fix spaces-as-wildcards completion
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue