[PR #634] [MERGED] fix(editor-view): clear stale glyphs when text shrinks #675

Closed
opened 2026-03-02 23:47:37 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/634
Author: @kitlangton
Created: 2/5/2026
Status: Merged
Merged: 2/6/2026
Merged by: @kommander

Base: mainHead: fix/placeholder-ghosting


📝 Commits (1)

  • 99890ab fix(editor-view): mark virtual lines dirty when placeholder text changes

📊 Changes

2 files changed (+76 additions, -4 deletions)

View changed files

📝 packages/core/src/zig/editor-view.zig (+4 -0)
📝 packages/core/src/zig/tests/editor-view_test.zig (+72 -4)

📄 Description

Closes https://github.com/anomalyco/opentui/issues/635 (reiterated below)

I was adding mode-specific placeholder text in opencode, such that shell mode shows a relevant bash example rather than the normal prompt example.

That exposed a rendering bug in OpenTUI: when switching from the longer normal-mode placeholder to the shorter shell-mode placeholder, trailing characters from the old placeholder stayed visible. Example:

1. Build mode placeholder (all good)
CleanShot 2026-02-05 at 18 55 20@2x

2. When switching to bash mode (OH NO! DEAR GOD NO!)
image

As you can see, the last bits of "Fix broken tests" aren't cleared as one might expect, leaving us with the hideous: Run a command... "pwd"roken tests

The Cause

Two things combined:

  • EditorView placeholder updates while placeholder is active did not always force virtual line recomputation.
  • The default alpha-blending path preserves destination chars for transparent-space overlays, which, while useful in certain contexts, led to the unwanted visual artifact in this case.

The Fix

  • packages/core/src/zig/editor-view.zig
    • Mark virtual lines dirty when placeholder styled text changes while placeholder is active.

Regression Coverage

  • packages/core/src/zig/tests/editor-view_test.zig
    • EditorView - placeholder long to short clears tail without full buffer clear
    • EditorView - placeholder clear preserves existing background

These tests fail without the full fix and pass with it.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/634 **Author:** [@kitlangton](https://github.com/kitlangton) **Created:** 2/5/2026 **Status:** ✅ Merged **Merged:** 2/6/2026 **Merged by:** [@kommander](https://github.com/kommander) **Base:** `main` ← **Head:** `fix/placeholder-ghosting` --- ### 📝 Commits (1) - [`99890ab`](https://github.com/anomalyco/opentui/commit/99890ab8af7f3f2727ddc3bf19bfb5b751a431b8) fix(editor-view): mark virtual lines dirty when placeholder text changes ### 📊 Changes **2 files changed** (+76 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/zig/editor-view.zig` (+4 -0) 📝 `packages/core/src/zig/tests/editor-view_test.zig` (+72 -4) </details> ### 📄 Description Closes https://github.com/anomalyco/opentui/issues/635 (reiterated below) I was adding mode-specific placeholder text in `opencode`, such that shell mode shows a relevant bash example rather than the normal prompt example. That exposed a rendering bug in OpenTUI: when switching from the longer normal-mode placeholder to the shorter shell-mode placeholder, trailing characters from the old placeholder stayed visible. Example: **1. Build mode placeholder** (all good) <img width="1620" height="416" alt="CleanShot 2026-02-05 at 18 55 20@2x" src="https://github.com/user-attachments/assets/a2fcc14d-6f59-4ee3-8f50-5d24fd8c3fea" /> **2. When switching to bash mode** (OH NO! DEAR GOD NO!) <img width="483" height="299" alt="image" src="https://github.com/user-attachments/assets/a3c34b82-5b81-4e9c-aa0e-a34ca9ac10f7" /> As you can see, the last bits of `"Fix broken tests"` aren't cleared as one might expect, leaving us with the hideous: `Run a command... "pwd"roken tests` ## The Cause Two things combined: - `EditorView` placeholder updates while placeholder is active did not always force virtual line recomputation. - The default alpha-blending path preserves destination chars for transparent-space overlays, which, while useful in certain contexts, led to the unwanted visual artifact in this case. ## The Fix - `packages/core/src/zig/editor-view.zig` - Mark virtual lines dirty when placeholder styled text changes while placeholder is active. ## Regression Coverage - `packages/core/src/zig/tests/editor-view_test.zig` - `EditorView - placeholder long to short clears tail without full buffer clear` - `EditorView - placeholder clear preserves existing background` These tests fail without the full fix and pass with it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 23:47:37 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#675
No description provided.