Skip to content

fix: avoid duplicate zsh prompts on resize - #48

Merged
Raiden-MeixElysia merged 1 commit into
ELY-Open-Source:mainfrom
zenaurora:fix-zsh-resize-prompt
Oct 30, 2026
Merged

Raiden-MeixElysia merged 1 commit into
ELY-Open-Source:mainfrom
zenaurora:fix-zsh-resize-prompt

Conversation

@zenaurora

Copy link
Copy Markdown
Contributor

Type

  • [FEATURE REQUEST]: a new feature or an improvement
  • [BUG REPORT]: a bug fix
  • [Other]: docs, refactoring, CI, dependencies or chores

What and why

zsh/P10k 在 terminal resize 时会重绘当前 prompt,但旧 prompt 已经被终端网格按新宽度重新排版并进入 history,导致每次缩放都多出一份

Bug details

  • Steps to reproduce:
    我使用 p10k + zsh 的情况下,发现如果输入命令之后调整一下终端左右宽度就发现大量的重复 prompt 的输出
  • Expected:
image
  • Actual:
image
  • Cause and fix:
    使用了一下 GPT6.1 sol 进行了一下修复
  1. zsh 给可重绘 prompt 加上 redraw=1 标记。

  2. 终端解析器把这个标记保存在 prompt 的 hyperlink metadata 中。

  3. resize 前识别当前活动 prompt,清除它和输入编辑区域的旧物理行,但保留 prompt 标识。

  4. zsh/P10k 随后只重绘一次,不再把旧 prompt 复制到 history。

我的本机上面没有 powershell ,fish 和 wsl,所以对于 zsh 相关的所有的测试均已经通过.AI 还额外写了一堆测试,如果没必要的话可以删掉这些

Raiden-MeixElysia added a commit that referenced this pull request Oct 30, 2026
@Raiden-MeixElysia
Raiden-MeixElysia merged commit e1d473b into ELY-Open-Source:main Oct 30, 2026
Raiden-MeixElysia added a commit that referenced this pull request Oct 30, 2026
@Raiden-MeixElysia

Copy link
Copy Markdown
Contributor

Thanks @zenaurora — shipped in 0.2.1 (https://github.com/ELY-Open-Source/ELYTerminal/releases/tag/v0.2.1). Review found that blanking the prompt's rows erased a background job's output, a continued command's first lines and the prompt without zle, and that the repeated sched reset $pipestatus, so it was reworked the way kitty does it: the prompt's rows are kept unreflowed and put back after the resize, PS2 is marked a secondary prompt, and themes like p10k get their start mark printed ahead of the prompt. Your zsh tests stayed, rewritten to rows kept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants