Skip to content

Fix layout shift when found text contains newlines in Find/Replace#11586

Merged
niksedk merged 1 commit into
SubtitleEdit:mainfrom
mjuhasz:fix/status-bar-newline-layout-shift
Jun 13, 2026
Merged

Fix layout shift when found text contains newlines in Find/Replace#11586
niksedk merged 1 commit into
SubtitleEdit:mainfrom
mjuhasz:fix/status-bar-newline-layout-shift

Conversation

@mjuhasz

@mjuhasz mjuhasz commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Problem

When searching with a regex pattern containing \n (e.g. \]\n), the matched text can include a literal newline character. This newline was embedded directly into the "Found '…' in line X, position Y" status message and displayed in a plain TextBlock in the main window footer. The TextBlock rendered the newline as a second line, doubling the footer height and causing all main window components (subtitle grid, toolbar, waveform) to shift upward. The shift reversed when the status message faded out after 3 seconds.

status.string.mov

Fix

Replace \r\n and \n with a middle dot (·, U+00B7) in the matched text before embedding it in the status message. The middle dot is in the Latin-1 block and is present in every font a user might select.

The same replacement is applied consistently in the OCR All Fixes list (ReplacementUsedItem, GuessUsedItem) and the Split/Break Long Lines preview (SplitBreakLongLinesViewModel), which previously used (U+21B5). That character is absent from several popular fonts (including the macOS default system font), causing it to render as a box when the user had switched away from Avalonia's default Inter font.

Files changed

  • src/ui/Features/Main/MainViewModel.cs — sanitize foundText at all four FoundXInLineYZ call sites (Find, FindNext, FindPrevious, HandleReplaceResult)
  • src/ui/Features/Ocr/FixEngine/ReplacementUsedItem.cs
  • src/ui/Features/Ocr/FixEngine/GuessUsedItem.cs
  • src/ui/Features/Tools/SplitBreakLongLines/SplitBreakLongLinesViewModel.cs

When searching with a regex containing \n, the matched text could contain
a literal newline. Embedding it in the "Found..." status message caused
the status bar TextBlock to render as two lines, expanding the footer and
shifting all main window components upward.

Replace \r\n and \n with a middle dot (·) in found text before display.
Also applied consistently to OCR All Fixes and Split/Break Long Lines
previews, which previously used ↵ (not present in SF Pro, Helvetica etc.).
@niksedk niksedk merged commit e3530b7 into SubtitleEdit:main Jun 13, 2026
2 checks passed
@mjuhasz mjuhasz deleted the fix/status-bar-newline-layout-shift branch June 13, 2026 19:46
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.

2 participants