Skip to content

fix(editor-view): clear stale glyphs when text shrinks#634

Merged
kommander merged 1 commit intoanomalyco:mainfrom
kitlangton:fix/placeholder-ghosting
Feb 6, 2026
Merged

fix(editor-view): clear stale glyphs when text shrinks#634
kommander merged 1 commit intoanomalyco:mainfrom
kitlangton:fix/placeholder-ghosting

Conversation

@kitlangton
Copy link
Collaborator

@kitlangton kitlangton commented Feb 5, 2026

Closes #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.

@kitlangton kitlangton force-pushed the fix/placeholder-ghosting branch from 20b9f04 to 7216e91 Compare February 5, 2026 23:52
@kitlangton kitlangton changed the title fix(editor-view): prevent placeholder ghosting when placeholder shrinks fix(editor-view): clear stale glyphs when text shrinks Feb 6, 2026
@kitlangton kitlangton force-pushed the fix/placeholder-ghosting branch 4 times, most recently from 2506259 to 5948d05 Compare February 6, 2026 01:13
When placeholder text was replaced while a placeholder was already
active, virtual lines were not recalculated. The view_id is registered
with the original buffer, not the placeholder, so the standard dirty-
flag mechanism does not detect this change. This caused stale glyphs
from the previous longer placeholder to remain visible.
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 6, 2026

@opentui/core

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core@634

@opentui/react

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/react@634

@opentui/solid

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/solid@634

@opentui/core-darwin-arm64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-darwin-arm64@634

@opentui/core-darwin-x64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-darwin-x64@634

@opentui/core-linux-arm64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-linux-arm64@634

@opentui/core-linux-x64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-linux-x64@634

@opentui/core-win32-arm64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-win32-arm64@634

@opentui/core-win32-x64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-win32-x64@634

commit: 99890ab

@kommander kommander merged commit f8ae055 into anomalyco:main Feb 6, 2026
6 checks passed
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.

Stale glyphs when replacing placeholder with shorter text

2 participants