fix(globalias): preserve quoted words and assignment values (#14092)

Only invoke alias completion when the complete shell word is an alias name. Completion otherwise treats assignment values and quoted text as standalone alias names, corrupting inputs such as DEBUG=1.

Add a real ZLE regression test covering the reported assignments, quotes, escaped aliases, filtering, and existing expansion behavior.

Assisted-by: OpenAI Codex
This commit is contained in:
Kunpeng Xie
2026-10-11 15:58:22 -07:00
committed by GitHub
parent 535aaaf924
commit eb29cdb33a
2 changed files with 86 additions and 1 deletions
+5 -1
View File
@@ -4,7 +4,11 @@ globalias() {
# (A) makes it an array even if there's only one element
local word=${${(Az)LBUFFER}[-1]}
if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$word] -eq 0 ]]; then
zle _expand_alias
# Completion also considers quoted strings and assignment values as aliases.
# Only expand when the complete shell word is an alias name.
if (( ${+aliases[$word]} || ${+galiases[$word]} )); then
zle _expand_alias
fi
zle expand-word
fi
zle self-insert