Skip to content

fix(zsh): prompt is not re-rendered on terminal resize, so baked right-side padding wraps #44

Description

@lemtoc

As of v0.3.0 (c73dc6c).

Summary

Line 1 right-alignment is implemented by baking spaces into PROMPT (lower_first_line pads to exactly columns, src/render/mod.rs:168). The string is rendered once per precmd with the COLUMNS value of that moment. When the terminal shrinks afterwards (pane split, window resize), zsh redisplays the same static string into a narrower terminal and the line wraps mid-segment:

… koutei/readOnly
 (ap-northeast-1)                                   22:16:
39

(observed after splitting a pane; the aws segment and the clock tear across three lines). The prompt only recovers at the next precmd.

Cause

src/shell/init.zsh registers preexec/precmd/zshexit/line-init hooks only — there is no TRAPWINCH. zsh updates COLUMNS and redisplays the prompt on SIGWINCH, but redisplay re-expands the existing PROMPT string; the padding computed for the old width is baked in. Any prompt that right-aligns via padding (rather than RPROMPT, which zsh reflows natively but only supports on the final line) must re-render on resize — powerlevel10k and starship both do this.

Proposed fix

  • Add a TRAPWINCH handler that re-sends a render request with the fresh COLUMNS and applies the reply via the existing zle -F update path (_nova_drain_and_redraw + zle reset-prompt). All plumbing already exists; the handler is a few lines.
  • Preserve any user-defined TRAPWINCH (call the previous definition if present), and guard against non-ZLE contexts the way _nova_register_update_handler already does.
  • Debounce is likely unnecessary (interactive resizes generate few WINCHes and the worker render is cheap), but coalescing by generation counter already happens on the apply side (_nova_last_applied_gen).
  • Regression coverage belongs to the interactive harness (test(zsh): add an interactive zsh E2E harness (zpty) #24): resize the pty and assert the prompt re-renders without wrapping.

Notes


🤖 Generated with Claude Code — Claude Fable 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Second priority: quality and infrastructurearea:zshComponent: zshbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions