-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Bug Report
Problem
During tab completion, Powerlevel10k's _p9k_on_expand
function continuously spams the following error pattern:
_p9k_on_expand:7: bad pattern: (utf|UTF)(-|)8
git commit
_p9k_on_expand:7: bad pattern: (utf|UTF)(-|)8
git commit
_p9k_on_expand:7: bad pattern: (utf|UTF)(-|)8
git commit
This creates an infinite loop of error messages that makes tab completion completely unusable. Ctrl+C is unresponsive, requiring the terminal window to be closed and reopened.
Root Cause Analysis
The issue stems from a malformed pattern in the __p9k_intro_locale
variable. When running typeset | grep -i utf
, the following problematic pattern is visible:
readonly __p9k_intro_locale='[[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]] && _p9k_init_locale && { [[ -n $LC_ALL ]] && local LC_ALL=$__p9k_locale || local LC_CTYPE=$__p9k_locale }'
The pattern (utf|UTF)(-|)8
appears to be malformed for zsh pattern matching, causing zsh to report "bad pattern" errors when it's evaluated during completion expansion.
Reproduction Steps
- Install Powerlevel10k with any completion system (fzf-tab, standard zsh completion, etc.)
- Type
git commit
(with a space) - Press TAB for completion
- Observe continuous error spam that cannot be interrupted with Ctrl+C
Environment
- OS: macOS 14.5 (Darwin 24.5.0)
- Zsh version: 5.9
- Powerlevel10k version: Latest (commit 36f3045)
- Terminal: iTerm2
- Locale: All UTF-8 (LANG=en_US.UTF-8, LC_ALL=en_US.UTF-8, LC_CTYPE=en_US.UTF-8)
Expected Behavior
Tab completion should work without generating error messages.
Actual Behavior
Tab completion triggers an infinite loop of "bad pattern" error messages from _p9k_on_expand:7
that cannot be interrupted, requiring terminal restart.
Workaround
The issue can be worked around by wrapping the _p9k_on_expand
function to suppress stderr:
if (( $+functions[_p9k_on_expand] )); then
functions[_p9k_on_expand_orig]=$functions[_p9k_on_expand]
_p9k_on_expand() {
{ _p9k_on_expand_orig "$@" } 2>/dev/null
}
fi
Additional Notes
- The error persists even with proper UTF-8 locale configuration
- The issue occurs regardless of the completion system used (tested with fzf-tab disabled)
- The pattern appears to be hardcoded in Powerlevel10k's locale detection logic
This seems to be a regex pattern that needs proper escaping for zsh pattern matching.