fix: add WithHardTabs/WithBackspace options and fix doc bugs#1722
Open
GautamKumarOffical wants to merge 3 commits into
Open
fix: add WithHardTabs/WithBackspace options and fix doc bugs#1722GautamKumarOffical wants to merge 3 commits into
GautamKumarOffical wants to merge 3 commits into
Conversation
Add WithHardTabs and WithBackspace ProgramOptions to allow users to explicitly control cursor movement optimizations, addressing issue charmbracelet#1635 where the auto-detected hard-tab optimization breaks column alignment in View() output. Also fix several documentation bugs: - InterruptMsg doc incorrectly says 'suspend' instead of 'interrupt' - ResumeMsg doc has grammar error ('listen' instead of 'listened') - BackgroundColorMsg example is missing return statement and has wrong [Update.Init] reference instead of [Model.Init] - KeyboardEnhancements doc example uses non-existent msg.ReportEventTypes field instead of msg.SupportsEventTypes() method - Remove duplicate KeyboardEnhancements doc comment Signed-off-by: Gautam Kumar <gautamkumarofficial@users.noreply.github.com>
Author
|
Hi! This PR adds WithHardTabs/WithBackspace options and fixes several doc bugs. All checks pass. Happy to make any adjustments. Thanks! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1722 +/- ##
==========================================
- Coverage 56.50% 55.92% -0.58%
==========================================
Files 25 25
Lines 1315 1325 +10
==========================================
- Hits 743 741 -2
- Misses 482 491 +9
- Partials 90 93 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
added 2 commits
June 18, 2026 07:57
Adds tests to improve code coverage for the new WithHardTabs and WithBackspace options introduced in this PR. Closes charmbracelet#1722
Check backspaceOverride instead of hardTabsOverride when testing WithBackspace(false). Signed-off-by: Gautam Kumar <gautamkumarofficial@users.noreply.github.com>
Author
|
Fixed a typo in the WithBackspace test — was checking |
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.
Summary
This PR addresses issue #1635 and fixes several documentation bugs.
New
WithHardTabsandWithBackspaceoptionsThe v2 cursor optimization in
cursedRendererauto-detects the terminal'sTAB0flag viatermiosand replaces runs of space cells with\tcharacters as a cursor-movement optimization. This silently corrupts application output that relies on precise space-based column alignment (see #1635).Previously there was no way to disable this behavior. This PR adds:
tea.WithHardTabs(bool)— explicitly enable or disable hard tab optimizationtea.WithBackspace(bool)— explicitly enable or disable backspace optimizationWhen these options are not set, the auto-detection from
termioscontinues to work as before. When they are set, the explicit value takes precedence.Usage:
Documentation fixes
InterruptMsgdoc incorrectly said "signals the program should suspend" — changed to "interrupt"ResumeMsgdoc had a grammar error ("listen" → "listened")BackgroundColorMsgexample was missingreturn m, niland referenced[Update.Init]instead of[Model.Init]KeyboardEnhancementsdoc example used non-existentmsg.ReportEventTypesfield instead ofmsg.SupportsEventTypes()methodKeyboardEnhancementsdoc commentTesting
All existing tests pass. The changes are backward-compatible — no existing behavior changes unless
WithHardTabs/WithBackspaceare explicitly set.