feat: add WithoutHardTabs option to disable tab cursor optimization#1647
Open
majiayu000 wants to merge 2 commits intocharmbracelet:mainfrom
Open
feat: add WithoutHardTabs option to disable tab cursor optimization#1647majiayu000 wants to merge 2 commits intocharmbracelet:mainfrom
majiayu000 wants to merge 2 commits intocharmbracelet:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1614
SetTabStops()in the cursed renderer was being called unconditionally,even when
hardTabswas false. This meant tab stop sequences were alwayswritten to the terminal, which breaks column alignment for apps that use
literal tab characters in their
View()output.Changes:
WithoutHardTabs()program option that setsdisableHardTabsonthe Program struct. When set, the hard tabs optimization flag is forced
off before it reaches the renderer.
SetTabStops()calls incursed_renderer.goconditional on thehardTabsflag actually being true (lines 64 and 596). Previouslythese ran regardless.
options_test.goverifying the option works.