fix(init): eliminate a potential recursive definition

This commit is contained in:
NaroZeol 2024-11-15 06:29:43 +08:00
parent b4bec448df
commit 28997dab4c

View File

@ -62,19 +62,17 @@ starship_zle-keymap-select() {
zle reset-prompt
}
## Check for existing keymap-select widget.
# zle-keymap-select is a special widget so it'll be "user:fnName" or nothing. Let's get fnName only.
__starship_preserved_zle_keymap_select=${widgets[zle-keymap-select]#user:}
if [[ -z $__starship_preserved_zle_keymap_select ]]; then
zle -N zle-keymap-select starship_zle-keymap-select;
else
# Define a wrapper fn to call the original widget fn and then Starship's.
starship_zle-keymap-select-wrapped() {
# Define a wrapper fn to call the original widget fn and then Starship's.
starship_zle-keymap-select-wrapped() {
if [[ -n $__starship_preserved_zle_keymap_select ]] &&\
[[ "$__starship_preserved_zle_keymap_select" != "starship_zle-keymap-select-wrapped" ]]; then
$__starship_preserved_zle_keymap_select "$@";
starship_zle-keymap-select "$@";
}
zle -N zle-keymap-select starship_zle-keymap-select-wrapped;
fi
fi
starship_zle-keymap-select "$@";
}
zle -N zle-keymap-select starship_zle-keymap-select-wrapped;
export STARSHIP_SHELL="zsh"