Skip to content

Collapse messages with excessive newlines regardless of character count#14863

Open
Vishvendra47 wants to merge 1 commit into
signalapp:mainfrom
Vishvendra47:fix/collapsed-message-newlines
Open

Collapse messages with excessive newlines regardless of character count#14863
Vishvendra47 wants to merge 1 commit into
signalapp:mainfrom
Vishvendra47:fix/collapsed-message-newlines

Conversation

@Vishvendra47

Copy link
Copy Markdown

First time contributor checklist

Contributor checklist

  • I am following the Code Style Guidelines
  • I have tested my contribution on these devices:
    • Virtual device (emulator), Android 15
  • My contribution is fully baked and ready to be merged as is
  • I ensure that all the open issues my contribution fixes are mentioned in the commit message of my first commit using the Fixes #1234 syntax

Description

Previously, whether a message needed a "Read more" overflow was decided purely by character count (MAX_BODY_DISPLAY_LENGTH). Messages with very few characters but a large number of newlines were never flagged as overflowing, causing them to render at full height and degrade scroll performance (see #14861).

This adds a line-count check (MAX_BODY_DISPLAY_LINES) alongside the existing character-count check in hasExtraText(), and introduces getMaxBodyDisplayLength() to compute the correct truncation point based on whichever limit (characters or lines) is hit first.

How I tested it:

  • Built the project and ran it on a virtual device (Android 15).
  • Sent a message consisting of a short string with a large number of newlines (e.g. a single character, followed by many blank lines, followed by another character) and confirmed it now correctly collapses with a "Read more" option, and that scrolling near it is smooth.
  • Verified that existing behavior for normal long text messages (1000+ characters, few/no newlines) still collapses correctly as before, confirming no regression.

Fixes #14861

Previously, whether a message needed a 'Read more' overflow was
decided purely by character count (MAX_BODY_DISPLAY_LENGTH).
Messages with very few characters but a large number of newlines
were never flagged as overflowing, causing them to render at full
height and degrade scroll performance.

This adds a line-count check (MAX_BODY_DISPLAY_LINES) alongside the
existing character-count check in hasExtraText(), and introduces
getMaxBodyDisplayLength() to compute the correct truncation point
based on whichever limit (chars or lines) is hit first.

Fixes signalapp#14861
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.

Collapsing messages is broken

1 participant