Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim whitespace at the end of messages #2169

Merged
merged 3 commits into from
Jan 5, 2024

Conversation

jmartinesp
Copy link
Member

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Trim whitespace at the end of both formatted and plain text messages. We don't trim leading whitespace in case it's used for formatting or some nice ASCII art.

             (__)    
     `\------(oo)
       ||    (__)
       ||w--||     \|/
   \|/

Motivation and context

Fixes #2099.

Screenshots / GIFs

Tests

  • Send a message with one or several trailing whitespaces or new lines.

In the timeline those extra whitespace chars should be gone.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14

Checklist

@jmartinesp jmartinesp requested a review from a team as a code owner January 5, 2024 08:24
@jmartinesp jmartinesp requested review from bmarty and removed request for a team January 5, 2024 08:24
Copy link
Contributor

github-actions bot commented Jan 5, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/RFfXfE

Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (4948748) 66.98% compared to head (877ec84) 66.99%.

Files Patch % Lines
...oid/libraries/matrix/ui/messages/ToHtmlDocument.kt 33.33% 0 Missing and 2 partials ⚠️
...ctories/event/TimelineItemContentMessageFactory.kt 96.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2169   +/-   ##
========================================
  Coverage    66.98%   66.99%           
========================================
  Files         1376     1376           
  Lines        34193    34201    +8     
  Branches      7441     7443    +2     
========================================
+ Hits         22905    22912    +7     
  Misses        7672     7672           
- Partials      3616     3617    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but this code will trim only the last line, IIUC how trimEnd() works. Would it have sense to trimEnd all lines of the message? For instance having (with _ replacing for clarity):

a____
b__
c

become

a
b
c

?
We could replace trimEnd() with lines().joinToString(transform = String::trimEnd, separator = "\n") to do it.

On the other side I do not really like to apply post treatment on Events that have been sent...

@frebib
Copy link
Contributor

frebib commented Jan 5, 2024

This doesn't seem to solve the issue in the ping room, because I think you're only trimming the body and not the formattedBody where the issue actually is?

@jmartinesp
Copy link
Member Author

This doesn't seem to solve the issue in the ping room, because I think you're only trimming the body and not the formattedBody where the issue actually is?

Sorry, you're right. I applied the trimEnd() at the wrong place 🤦 .

@jmartinesp jmartinesp force-pushed the fix/jme/2099-trim-whitespace-at-end-of-messages branch from 899900f to a67f9ea Compare January 5, 2024 10:33
@frebib
Copy link
Contributor

frebib commented Jan 5, 2024

Screenshot_20240105-104227.png

Looks great! Thanks

@jmartinesp jmartinesp added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Jan 5, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Jan 5, 2024
Copy link

sonarcloud bot commented Jan 5, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@jmartinesp jmartinesp merged commit e04780f into develop Jan 5, 2024
18 checks passed
@jmartinesp jmartinesp deleted the fix/jme/2099-trim-whitespace-at-end-of-messages branch January 5, 2024 11:40
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.

Message bubbles render trailing newlines from formatted HTML body
3 participants