Skip to content

fix(renderer): restore DECST8C tab stops after resize - #1839

Open
Anandb71 wants to merge 1 commit into
charmbracelet:mainfrom
Anandb71:fix/1838-restore-tab-stops-on-resize
Open

Anandb71 wants to merge 1 commit into
charmbracelet:mainfrom
Anandb71:fix/1838-restore-tab-stops-on-resize

Conversation

@Anandb71

@Anandb71 Anandb71 commented Oct 4, 2026

Copy link
Copy Markdown

Description

Fixes #1838.

Hard-tab cursor moves rely on terminal tab stops set with DECST8C (ESC[?5W). The cursed renderer only emitted that sequence on the first render (s.starting && s.hardTabs). After a widening resize, the renderer's own tab-stop model grew with Resize, but the terminal still only had stops for the old width. Tabs past the last known stop landed on the right margin and corrupted the row (especially near the right edge).

When hard tabs are enabled, resize() now:

  1. Calls SetTabStops(s.width) for the new width (same as reset()).
  2. Re-emits ansi.SetTabEvery8Columns, matching the startup path.

Hard tabs off is unchanged. The initial start-time restore is unchanged.

Checklist

  • Does your PR pass tests?
  • Have you written new tests for your changes?
  • Have you lint your code locally prior to submission?

Testing

go test ./... -count=1
# ok charm.land/bubbletea/v2

TestCursedRenderer_restoresTabStopsOnResize checks that DECST8C is emitted on the first render and again after a widen when hard tabs are on, and not at all when hard tabs are off.

AI assistance

This change was written with the help of an AI coding assistant (Cursor).

Hard-tab cursor moves use terminal tab stops that were only set at
startup. After a widen, columns beyond the old width had no stops, so
tabs landed on the right margin and corrupted the row.

When hard tabs are enabled, resize now refreshes SetTabStops for the
new width and re-emits DECST8C, matching the startup path.

Fixes charmbracelet#1838
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.

Hard-tab cursor moves break after widening the window: DECST8C is only sent at startup

1 participant