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

Refactor emote parsing, fix some emote display issues #529

Merged
merged 5 commits into from
Feb 7, 2024

Conversation

Nogesma
Copy link
Contributor

@Nogesma Nogesma commented Feb 1, 2024

While cleaning up my code for the emote picker, I ended up rewriting most of the emote parsing code.
To avoid making the other PR even bigger, here's a separate one.

Most important bug fixes are the emote overlays that should now be properly centered on top of the base emote, and emotes smaller than the width of 1 terminal cell were not being displayed.

There is a more complete list of fixes in my commits messages.

I also added a bunch of tests for the conversion from &str to vec![Span].

A lot of those additions are from adding tests, so hopefully this is not too large of a PR to review.

Let me know if you find any issues, or need any changes.

Copy link

codecov bot commented Feb 1, 2024

Codecov Report

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

Comparison is base (f7746a7) 7.32% compared to head (7e08ecf) 15.72%.

❗ Current head 7e08ecf differs from pull request most recent head 841afa5. Consider uploading reports for the commit 841afa5 to get more accurate results

Files Patch % Lines
src/handlers/data.rs 75.42% 100 Missing ⚠️
src/emotes/mod.rs 0.00% 18 Missing ⚠️
src/utils/emotes.rs 95.52% 6 Missing ⚠️
src/emotes/graphics_protocol.rs 0.00% 1 Missing ⚠️
src/main.rs 0.00% 1 Missing ⚠️
src/ui/components/chat.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##            main     #529      +/-   ##
=========================================
+ Coverage   7.32%   15.72%   +8.39%     
=========================================
  Files         39       40       +1     
  Lines       4161     4514     +353     
=========================================
+ Hits         305      710     +405     
+ Misses      3856     3804      -52     

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

@Xithrius
Copy link
Owner

Xithrius commented Feb 1, 2024

Just confirming so I don't accidently nuke your other branch - you'd like to get this merged before #524, yeah?

@Nogesma
Copy link
Contributor Author

Nogesma commented Feb 1, 2024

Yes, I still need to clean up and split into different commits the other branch.

@Xithrius
Copy link
Owner

Xithrius commented Feb 2, 2024

I believe I'll be able to go over this code in the next couple of days.

- Split the to_vec::highlight function into get_emote_span, highlight,
  and build_line
- Fix bug where username highlights was using byte indices, and search
  highlight was using char indices.
- Don't format and clone time_sent string if config.show_datetimes is
  false
- Fix crash when running with both show_datetimes and username_shown set
  to false
- Fix right_align_usernames offset with emojis in username, fix overflow
  when usernames were > NAME_MAX_CHARACTERS len
- Fix emotes smaller than one cell being skipped when trying to display
  them
- Move some emote related functions into utils/
- Add some test for build_line and related functions
@Nogesma Nogesma force-pushed the refactor/emote-parsing branch from 3bbd79f to 7ea1157 Compare February 4, 2024 19:34
I found out kitty does not need to have the DIACRITICS_ZERO specified,
and we can avoid it entirely.
This also removes the Spans(ZERO_WIDTH_SPACE) between emotes/text, as
they are not needed, and were causing rendering issues with ratatui.
Copy link
Owner

@Xithrius Xithrius left a comment

Choose a reason for hiding this comment

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

It's been a good chunk of time since I've reviewed stuff like this, but I haven't been able to spot anything out of the ordinary.

Everything looked normal when running this branch as well.

Thank you once again!

@Xithrius Xithrius enabled auto-merge (squash) February 7, 2024 07:02
@Xithrius Xithrius merged commit 60c0b56 into Xithrius:main Feb 7, 2024
6 checks passed
@Nogesma Nogesma deleted the refactor/emote-parsing branch February 28, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants