Conversation
BorderElement truncated and aligned its title by string length, so a CJK title, two cells per char, overdrew the right corner and whatever was beside it, and truncating "ab😀cd" left a lone high surrogate. Truncate with TextElement.TakeCells and compute the Center and Right offsets with MeasureCells, the helpers #141 added for TextElement. Fixes #171 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2kkxDaFKYetxhPcC9
|
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 #171
What changed
TUI/Elements/Primitives/BorderElement.cs: the title is now truncated withTextElement.TakeCells(title, maxTitleWidth)instead oftitle[..maxTitleWidth]. The Center and Right offsets now useTextElement.MeasureCells(titleWithPadding)instead of.Length. These are the helpers TextElement draws CJK and other wide text past its content area and over the enclosing border, and cuts emoji mid-surrogate #141 added forTextElement. A CJK title, two cells per char, no longer overdraws the right corner, and a cut never lands inside a surrogate pair.Tests
New cases in
TUI.Test/BorderElementRenderTests.cs:WideTitleNeverExtendsPastTheRightBordercovers CJK and emoji titles, some that fit and some that need truncating, in everyTitleAlignment. It checks that the title write starts at x ≥ 1, that its last cell is at or beforeWidth - 2(measured with Spectre's own cell width), and that it holds no unpaired surrogate.WideTitleThatFitsIsCentredByCellWidth:" 日本語 "in a 20-wide border is drawn whole at x = 6.TruncatedEmojiTitleIsNotSplitMidSurrogatePair:"ab😀cd"at width 7 draws" ab ".With the
BorderElement.cschange reverted, 16 of these cases fail. With it, all pass. Full suite (dotnet test): 368/368 pass, and the Release build has no new warnings.This branch starts from
mainand doesn't depend on #261 (the package-validation fix for #259). Until #261 lands, a push build ofmainstill fails at pack.Generated by Claude Code