Skip to content

feat: add WithoutHardTabs option to disable tab cursor optimization#1647

Open
majiayu000 wants to merge 2 commits intocharmbracelet:mainfrom
majiayu000:fix/issue-1614-hard-tabs-opt-out
Open

feat: add WithoutHardTabs option to disable tab cursor optimization#1647
majiayu000 wants to merge 2 commits intocharmbracelet:mainfrom
majiayu000:fix/issue-1614-hard-tabs-opt-out

Conversation

@majiayu000
Copy link
Copy Markdown

Fixes #1614

SetTabStops() in the cursed renderer was being called unconditionally,
even when hardTabs was false. This meant tab stop sequences were always
written to the terminal, which breaks column alignment for apps that use
literal tab characters in their View() output.

Changes:

  • Add WithoutHardTabs() program option that sets disableHardTabs on
    the Program struct. When set, the hard tabs optimization flag is forced
    off before it reaches the renderer.
  • Make SetTabStops() calls in cursed_renderer.go conditional on the
    hardTabs flag actually being true (lines 64 and 596). Previously
    these ran regardless.
  • Test in options_test.go verifying the option works.

When the terminal supports hard tabs, Bubble Tea uses them for cursor
movement optimization. This can break column alignment in View() output
when tab stop positions don't match the expected layout.

Add WithoutHardTabs() ProgramOption that lets users disable this
optimization while keeping other cursor movement optimizations intact.

Closes charmbracelet#1614

Signed-off-by: majiayu000 <1835304752@qq.com>
SetTabStops(width) was called unconditionally in both setOptimizations()
and reset(), which always enabled the capHT capability regardless of the
hardTabs setting. Now call SetTabStops(-1) when hardTabs is false to
properly disable the optimization.

Signed-off-by: majiayu000 <1835304752@qq.com>
@majiayu000 majiayu000 marked this pull request as ready for review March 28, 2026 03:47
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.

[v2] Hard-tab cursor optimization silently breaks column alignment in View() output

1 participant