← Back to Pull requests

fix(vt): erase the whole wide character when EL or ED starts on its second cell #1228

Open
unknown opened this pull request with 347 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 09, 2026 03:13 UTC
Author

When the cursor is on the second cell of a wide character, CSI 0 K and CSI 0 J in the vt emulator erased only that second cell. The first cell kept the wide character, so the character was left split. Ghostty's EL and ED pages say "if a multi-cell character would be split, erase the full multi-cell character" (https://ghostty.org/docs/vt/csi/el, https://ghostty.org/docs/vt/csi/ed). This is EL V-4 from that page:

8 columns: "AB橋DE" "\033[4G" "\033[0K"
expected: |AB_c____|
before:   橋 still in column 2, only column 3 cleared

eraseToLineEnd and eraseBelow now start one column to the left when the cell before the cursor holds a wide character. I put that check in a small eraseStart helper so both use it. The erase-left cases already come out right, because the second cell of a wide character is blank.

Review here also showed that putRune left the first cell marked wide when a narrow character overwrote the second cell, so a later erase reached one cell too far left. putRune now clears that first cell and sends it to the backend, as DCH and ICH already do.

Tests: TestELv4 and TestEDv3 in vt/tests/emulate_test.go are EL V-4 and ED V-3 from the Ghostty pages, in the same style as the other ported tests. On main they fail with:

--- FAIL: TestELv4 (0.00s)
    emulate_test.go:1560: bad content 2,0 (expected "" got "橋")
--- FAIL: TestEDv3 (0.00s)
    emulate_test.go:1589: bad content 2,1 (expected "" got "橋")

TestELv5, TestELv6 and TestPutRuneOverwriteWideSecondCell cover the putRune part; the last one fails on main because the first cell is never sent to the backend.

go test ./... passes (under script, as in CI), go test -race ./vt/... passes, gofmt -l and go vet are clean, and golangci-lint reports nothing new in vt. This is separate from #1227 (pending wrap on EL/ED). They change different lines of vt/emulate.go, but both add their tests after TestDLv4, so whichever lands second needs a small merge in vt/tests/emulate_test.go. Not run: Windows and wasm CI.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->

Summary by CodeRabbit

Bug Fixes
Erase-in-line and erase-in-display commands now correctly clear wide characters when the cursor is on the character’s second cell. Erase-in-line preserves content before the character, while erase-in-display clears the affected character and the remaining display, including subsequent rows.
* Overwriting the second cell of a wide character now clears its first cell. Subsequent erase operations clear both cells and apply the expected background colors, including when an erase is repeated.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Diff: 347 lines (+260 / -87) across 4 files Reviewer: yxshee Review duration: 31973m
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.47) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 347 lines diff across 4 files
0.47
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
42%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.350
Shallow Review Depth shallow_review_depth
0.344
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #1228"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 43.0% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 47.4% (MEDIUM) · Higher = larger blast radius
47.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 43.0% · Lower = rushed or shallow review
43.0%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 27% · Safe to merge
27%
Repository