Skip to content

fix(display): unify line renderer and restore right-edge wrap handling#117

Merged
maxlandon merged 1 commit into
masterfrom
dev
Jul 5, 2026
Merged

fix(display): unify line renderer and restore right-edge wrap handling#117
maxlandon merged 1 commit into
masterfrom
dev

Conversation

@maxlandon

Copy link
Copy Markdown
Member

Problem

Two issues, one root cause.

1. Right-edge redraw regression (still present on master). When editable input lands exactly on the terminal's right edge while the prompt is on the bottom row, terminals leave the cursor in a pending-wrap state. The main render path still emitted clear-to-end-of-line there, erasing the edge glyph and wedging the redraw — typing past the edge scrolled a row per keypress or stalled. This is the bug PR #112 by @rztaylor fixed; that PR was closed without explanation and never merged. I confirmed the bug reproduces on current master (the PR's regression test times out) and that the fix resolves it.

2. Duplicated render functions. The display refactor (b735972) copied displayLine into displayLineRefactored for the main render path but dropped the original's right-edge (lineCol == 0) handling — that dropped block is the regression above. The two functions then lived on as near-identical copies:

  • displayLineRefactored (refresh.go) → main per-keystroke path
  • displayLine (engine.go) → only RefreshTransient

They had already drifted: the inline-suggestion work (#114) had to patch both, and #112 patched only one. A latent trap.

Fix

Collapse them into a single displayLine, shared by both the main refresh path (renderInputArea) and the transient-prompt redraw (RefreshTransient), carrying correct right-edge handling:

  • Skip clear-to-end-of-line when the rendered input sits in the pending-wrap state (it can erase the edge glyph).
  • Force the pending wrap (NewlineReturn) before any later clear/cursor-movement sequences.

The transient path already appended its own NewlineReturn, and the old legacy displayLine also emitted one at the right edge, so the newline count in that path is unchanged.

Testing

  • Includes the PTY regression test from Fix right-edge redraw at terminal bottom #112 (credited to @rztaylor). It fails on master (input wedges at the right edge, times out) and passes with this change.
  • go build, go vet, and go test ./... all pass — full display suite (including transient/drift PTY tests) green, no regressions.

Supersedes #112.

The display refactor (b735972) copied displayLine into displayLineRefactored
for the main render path but dropped the pending-wrap handling the original
had for input landing exactly on the terminal's right edge. Since the copy is
the per-keystroke path, typing past the right edge on the bottom row erased the
edge glyph and wedged the redraw (scrolling a row per key). The two functions
otherwise drifted as identical copies — inline-suggestion work had to patch
both, and this fix had to patch only one.

Collapse them into a single displayLine used by both the main refresh path
(renderInputArea) and the transient-prompt redraw (RefreshTransient), and give
it correct right-edge handling: skip clear-to-end-of-line in the terminal's
pending-wrap state (it can erase the edge glyph), then force the wrap before
later clear/cursor-movement sequences.

Includes the PTY regression test from PR #112 by @rztaylor, which fails without
the fix (input wedges at the right edge) and passes with it.

Co-authored-by: rztaylor <rztaylor@users.noreply.github.com>
@maxlandon maxlandon merged commit d3aedcb into master Jul 5, 2026
9 checks passed
@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.52%. Comparing base (7ee6a10) to head (ef40244).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #117      +/-   ##
==========================================
+ Coverage   39.33%   39.52%   +0.18%     
==========================================
  Files          60       60              
  Lines        9610     9592      -18     
==========================================
+ Hits         3780     3791      +11     
+ Misses       5742     5713      -29     
  Partials       88       88              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant