Skip to content

fix: truncate preview message text on rune boundary#10

Merged
brtkwr merged 1 commit into
mainfrom
fix/preview-rune-truncation
Jun 22, 2026
Merged

fix: truncate preview message text on rune boundary#10
brtkwr merged 1 commit into
mainfrom
fix/preview-rune-truncation

Conversation

@brtkwr

@brtkwr brtkwr commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

What

renderPreview capped each message at 500 bytes with text[:500]. A message of multibyte text (CJK, emoji) cut at byte 500 splits a rune and emits invalid UTF-8 into the preview pane.

Same bug class as #4 (rune-safe truncate/padRight/highlight), but a separate call site in the preview that #4 didn't touch. Slices on runes now.

Tests

  • TestRenderPreviewLongMultibyteMessageStaysValidUTF8 - renders a preview of an 800-rune multibyte message and asserts the output is valid UTF-8 (fails under the old byte slice).
  • go test -cover = 69.1%.

renderPreview capped each message at 500 bytes via text[:500]. A
message of multibyte text (CJK, emoji) cut at byte 500 splits a rune
and emits invalid UTF-8 into the preview. Slice on runes instead.

Same class as the rune-safety fix in #4, but a separate call site in
the preview path.
@brtkwr brtkwr merged commit d1e2404 into main Jun 22, 2026
1 check passed
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.

1 participant