Skip to content

Normalise control characters in a border title like TextElement text [patch] - #250

Merged
matt-edmondson merged 2 commits into
mainfrom
fix/border-title-control-chars-222
Nov 11, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
fix/border-title-control-chars-222

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Summary

BorderElement.GetSingleLineTitle() replaced only line breaks. A tab or any other C0/C1 control character in Title therefore reached IConsoleProvider.WriteAt raw. Spectre drew a replacement glyph for a tab, any other provider got the raw bytes (the same terminal-escape path #159 closed for TextElement), and the measured title width didn't match what was drawn.

The title now goes through TextElement.NormalizeControlCharacters after the line breaks are replaced, so:

  • tabs expand to spaces exactly as in TextElement
  • other control characters become U+FFFD
  • drawing and measuring use the same string

Tests

  • New TitleControlCharactersAreNormalisedLikeTextElement (tab, ESC sequence, BEL + C1 CSI). It checks that no write carries a control character, that the drawn title is the normalised text, and that the measured width matches. It fails on main (3/3 cases) and passes with the fix.
  • Full suite: 330/330 pass.

Fixes #222


Generated by Claude Code

…[patch]

BorderElement.GetSingleLineTitle replaced only line breaks, so a tab or any
other C0/C1 control character in Title reached the console provider raw.
Spectre drew a replacement glyph for a tab, any other provider received the
raw bytes (the terminal-escape path #159 closed for TextElement), and the
measured title width disagreed with what was drawn.

The title now goes through TextElement.NormalizeControlCharacters after the
line-break replacement, so tabs expand to spaces, other control characters
become the placeholder, and drawing and measuring use the same string.

Fixes #222

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW2U95Ey8C2h9t4Ljwn
…rol-chars-222

# Conflicts:
#	TUI.Test/BorderElementRenderTests.cs
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 52d7930 into main Nov 11, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/border-title-control-chars-222 branch November 11, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BorderElement title passes tabs and control characters raw to the console provider (renders "Name�Value")

2 participants