zsh-autocomplete: zsh-autocomplete breaks p10k transient prompt

@marlonrichert excuse me for a rather elliptical issue report. The “transient prompt” feature of Powerlevel10k works only once, and then stops, if zsh-autocomplete is included in the configuration. This wouldn’t be the end of the world, as far as I’m concerned, but I’m worried it might be a symptom of an underlying low-level or design issue, with unexpected consequences.

I’d appreciate your advice on how to proceed, if at all. This might not be a “bug” but an incompatibility problem between the two plugins involved. Semantics aside, here are two extraordinary plugins by different authors, and it would be nice to be able to run them in parallel.

(I faced a similar conflict between your zsh-snap and p10k two days ago, which would unpredictably cause zsh to seg-fault. Running low on time, I didn’t report that one, instead refactoring my .zshrc to source plugins directly. The coexistence of the two lazy-loading mechanisms, yours and his, may not be harmonious.)

Thanks for your time.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 30 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@marlonrichert, thank you very much.

@marlonrichert indeed this seems to work!

Fixed.

This issue is caused by zsh-autocomplete removing zle-line-finished hooks from all other plugins. Powerlevel10k installs a zle-line-finished hook and then zsh-autocomplete removes it. To reproduce:

% zsh -f
% git clone --depth=1 https://github.com/marlonrichert/zsh-autocomplete.git
% zle-line-finish() print '\nzle-line-finish'; zle -N zle-line-finish
% source zsh-autocomplete/zsh-autocomplete.plugin.zsh
zle-line-finish

% true
%

Notice how “zle-line-finish” stops being printed once zsh-autocomplete is loaded. Let’s see how the hook looks like:

% echo $widgets[zle-line-finish]
user:azhw:zle-line-finish
% functions azhw:zle-line-finish
azhw:zle-line-finish () {
        local -a hook_widgets
        local hook
        zstyle -a $WIDGET widgets hook_widgets
        for hook in "${(@)${(@on)hook_widgets[@]}#<->:}"
        do
                if [[ "$hook" = user:* ]]
                then
                        zle "$hook" -N -- "$@"
                else
                        zle "$hook" -Nw -- "$@"
                fi || return
        done
        return 0
}
% zstyle -a zle-line-finish widgets hooks && typeset -p hooks
typeset -a hooks=( 1:.autocomplete.key.line-finish 2:.autocomplete.async.clear )
% functions .autocomplete.key.line-finish
.autocomplete.key.line-finish () {
        echoti rmkx
        return 0
}
% functions .autocomplete.async.clear
.autocomplete.async.clear () {
        zle -Rc
        .autocomplete.async.stop
        .autocomplete.async.reset-context
        return 0
}
% functions .autocomplete.async.stop
.autocomplete.async.stop () {
        .autocomplete.async.kill _autocomplete__async_complete_fd _autocomplete__async_complete_pid
        .autocomplete.async.kill _autocomplete__async_timeout_fd _autocomplete__async_timeout_pid
        return 0
}
% functions .autocomplete.async.reset-context
.autocomplete.async.reset-context () {
        typeset -gH curcontext=''
        zstyle -s :autocomplete: default-context curcontext
        return 0
}

As you can see, nothing in there invokes the original zle-line-finish hook.

Edit: I’m not subscribed to this issue. Mention me explicitly if you need my response but please do that only if really necessary.

OK, I can see it now when I try. I have no idea what causes this or how to fix it. You might have better luck filing an issue with Powerlevel10k.