Open LuckyWindsck opened 1 year ago
I just found that this is a duplicate issue of #90 (as well as #102 and #113). However all of them are closed and this problem still exists. I am not really sure what happened.
It seems like that the default zle widget of tab
key ("^I"
) is expand-or-complete
, and invoking the redisplay
widget after expand-or-complete
widget can solve this problem.
This is how Oh My Zsh implements the expand-or-complete-with-dots
widget, and bind it to tab
key ("^I"
).
So anyone who has similar problem can just use the workaround states above, or follow Oh My Zsh to define a zle widget like this:
expand-or-complete-then-redisplay() {
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-then-redisplay
# Set the function as the default tab completion widget
bindkey "^I" expand-or-complete-with-dots
add-zle-hook-widget
. However, we need the memo feature, so using add-zle-hook-widget
is gated behind a version check for 5.9 or later. If you use the homebrew version of zsh, you shouldn't keep seeing this.@phy1729: If you use the homebrew version of zsh, you shouldn't keep seeing this.
I am using the default version of zsh provided by macOS, should I installed another zsh via homebrew and use that?
As long at you're using at least zsh 5.9, the add-zle-hook-widget
way of running will be used and the issue should no longer appear.
@phy1729: As long at you're using at least zsh 5.9, the
add-zle-hook-widget
way of running will be used and the issue should no longer appear.
I will try a newer version of zsh later. Thanks for your help. If this solve the problem, I will close this issue.
$ echo $SHELL
/bin/zsh
$ $SHELL --version
zsh 5.8.1 (x86_64-apple-darwin21.0)
Unexpected behavior
After I input something and pressed tab key for completion, if the completion failed, the highlighting of command would disappear.
For example, I have installed this plugin through
antigen
, and installedHomebrew
as well as its zsh completion.First, I typed
brew z
and then I pressed
tab
key for completion. Note thatHomebrew
doesn't have a subcommand started withz
, so the completion will somehow fail. Now the syntax highlighting of commandbrew
disappeared.If I try something like
brew i
, then press tab, this time the completion will be successful. A completion list of subcommand started withi
will be displayed, and the syntax-highlighting work as expected.Workaround
I am using
oh-my-zsh
. I found that if I uncomment the following line in the default~/.zshrc
, the problem stated above will be solved.# COMPLETION_WAITING_DOTS="true"
I have investigated the
COMPLETION_WAITING_DOTS
feature ofoh-my-zsh
, but I cannot find anything useful to figure out the cause of unexpected behavior.Environment
Operating System: macOS 12.6.3 Zsh: zsh 5.8.1 (x86_64-apple-darwin21.0) zsh-users/zsh-syntax-highlighting: b2c910a85ed84cb7e5108e7cb3406a2e825a858f (commit hash) Antigen: v2.2.3 (ff391b5) Homebrew: 4.0.9