Skip to content

accept-line widget conflicts with zsh-syntax-highlighting and zsh-autosuggestions #3

Description

@djnesmith

Problem

The precmd hook zsh-clj-shell-install-widget re-installs the accept-line widget on every prompt. This conflicts with other plugins that also wrap accept-line, specifically zsh-syntax-highlighting and zsh-autosuggestions.

Symptoms

  • "No such widget 'zsh-clj-shell-orig-accept-line'" flashes briefly on every prompt redraw (e.g. after cd)
  • If the add-zsh-hook -d precmd zsh-clj-shell-install-widget workaround is removed, zsh: write error occurs instead
  • Both issues stem from the widget chain between plugins getting into a broken state

Root cause

zsh-clj-shell-install-widget runs on every precmd and calls zle -A accept-line zsh-clj-shell-orig-accept-line, which saves whatever is currently bound to accept-line — including other plugins' wrappers. When those plugins also maintain their own accept-line wrappers, the chain becomes circular or breaks, causing the errors above.

Reproduction

In .zshrc, load these plugins (via oh-my-zsh or manually):

plugins=(... zsh-autosuggestions zsh-syntax-highlighting)

Then source zsh-clj-shell last:

source ~/.oh-my-zsh/custom/plugins/zsh-clj-shell/zsh-clj-shell.plugin.zsh

Run any command (e.g. cd) and observe the error flash.

Suggested fix

Instead of re-installing the widget on every precmd, install it once at source time and trust that it stays in place. If re-installation is needed, check whether the current accept-line is already zsh-clj-shell-accept-line before overwriting (the check exists in zsh-clj-shell-install-widget but the zle -A save still runs and clobbers the chain).

Alternatively, consider using zle -A .accept-line zsh-clj-shell-orig-accept-line (note the dot prefix) to save the builtin accept-line rather than whatever wrapper is currently on top.

Environment

  • macOS (zsh 5.9)
  • oh-my-zsh with zsh-autosuggestions and zsh-syntax-highlighting
  • Starship prompt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions