fix(help): add context awareness to help-view width-based text truncation - #1032
Open
wolfwfr wants to merge 1 commit into
Open
fix(help): add context awareness to help-view width-based text truncation#1032wolfwfr wants to merge 1 commit into
wolfwfr wants to merge 1 commit into
Conversation
…tion This change prevents the width of the output of 'help.FullHelpView()' & 'help.ShortHelpView()' from exceeding the configured 'help.width' when 'help.width > 0', even when 'm.width' allows enough space for the first x items, but not enough for a tailing truncation-symbol (space+ellipsis). Prior to this change, the functions would return an entirely untruncated response that would exceed the configured 'help.width', in the herein described scenario.
wolfwfr
added a commit
to wolfwfr/dynamite
that referenced
this pull request
Aug 10, 2026
…o bug in bubbles/v2 pending PR: charmbracelet/bubbles#1032
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.
Description
This change prevents the width of the output of
help.FullHelpView()&help.ShortHelpView()from exceeding the configured 'help.width' whenhelp.width > 0, even whenhelp.widthallows enough space for the first x items, but not enough for a tailing truncation-symbol (space+ellipsis).Prior to this change, the functions would return an entirely untruncated response that would exceed the configured
help.width, in the herein described scenario.Technical Explanation
The pre-existing logic for assembling the string of help-items, would loop through the list of items, without awareness of whether another item would later be added too. When the configured
help.widthwould be sufficient for the current item, the item would be added. When the configuredhelp.widthwould not be sufficient, the logic would attempt to add atailinstead, consisting of a space & ellipsis (by default) with a total width of 2. If the remaining space was not sufficient for thistail, the logic would instead allow the addition of the item, and the next, and so forth.In effect, when a subset of help items would fit within
help.widthwith a margin of0-2, the functions would never truncate, and instead return all items, thus exceeding the configuredhelp.width.Fix
In order to fix this, I adjusted the loop to be context-aware, i.e. it only appends a help-item when it knows whether or not the item is going to be succeeded by another or not. If it is, the logic ensures there is enough space for BOTH the item & the
tail. If the item is not succeeded, it removes the requirement for space for thetail.The tests were expanded to ensure that the correct response is returned for all edge-cases.
When
help.width == 0, all items are returned. While this technically violates the configuredhelp.width, I did not alter this behaviour, because it sat behind a dedicated check and could make sense in use-cases wherewidthis not explicitly configured at all.AI Notice
In case it matters, no form of AI was involved in the design, implementation, or any other facet of this change.
CONTRIBUTING.md.DEMO
Short Help View
BUG

FIX

Full Help View
BUG

FIX
