Repository navigation
feat: support max width for wide_bar via {wide_bar:N} - #862
Open
amitcoder79 wants to merge 1 commit into
Open
amitcoder79 wants to merge 1 commit into
amitcoder79 wants to merge 1 commit into
Conversation
The width specifier on wide_bar was applied as padding (via
PaddedStringDisplay), which inflated the bar instead of capping it.
Skip the padding step for wide_bar and wide_msg, and pass the width
to the WideElement as a max_width cap used during expansion.
{wide_bar:20} now scales down with the terminal but never exceeds 20
visual columns.
Closes console-rs#789
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.
The width specifier on
wide_barwas applied as padding by the generic placeholder handler, inflating the output instead of capping the bar length. This makes{wide_bar:N}work as a max-width cap: the bar scales down with the terminal but never exceeds N visual columns.Changes
WideElement::Bargains amax_width: Option<usize>field, populated from the template width specifierexpandcapsleftwithmin(left, max)when the field is setPaddedStringDisplayforwide_barandwide_msgsince their width semantics are a cap, not paddingUsage
Testing
wide_bar_max_width_caps_bar_length— verifies unlimited{wide_bar}fills the terminal (50 cols) while{wide_bar:20}caps at exactly 20 visual columnsCloses #789