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(buffer): simplify set_stringn logic #1083

Merged
merged 2 commits into from
May 2, 2024
Merged

Conversation

EdJoPaTo
Copy link
Member

@EdJoPaTo EdJoPaTo commented May 2, 2024

Simplifies the logic. Instead of trying to figure out the max_offset in a seemingly complicated way keep the remaining_width and count down as long as there are characters left. This is way easier to understand for me what is going on.


Part of the improvements I did with #1049. As this is without _opt methods this can still panic (same as current code on wrong input).

Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.1%. Comparing base (366c2a0) to head (46ef759).

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1083     +/-   ##
=======================================
+ Coverage   89.4%   94.1%   +4.7%     
=======================================
  Files         61      61             
  Lines      15440   14619    -821     
=======================================
- Hits       13808   13764     -44     
+ Misses      1632     855    -777     

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

Copy link
Member

@joshka joshka left a comment

Choose a reason for hiding this comment

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

Looks good. A couple of comments

src/buffer/buffer.rs Show resolved Hide resolved
src/buffer/buffer.rs Outdated Show resolved Hide resolved
src/buffer/buffer.rs Show resolved Hide resolved
src/buffer/buffer.rs Show resolved Hide resolved
src/buffer/buffer.rs Show resolved Hide resolved
easier to read code due to less index assumptions
src/buffer/buffer.rs Show resolved Hide resolved
@joshka joshka merged commit baedc39 into main May 2, 2024
33 checks passed
@joshka joshka deleted the edjopato/buffer-set-string branch May 2, 2024 23:32
joshka added a commit that referenced this pull request May 5, 2024
This is a small universal style change to avoid making this change a
part of other PRs.

[rationale](#1083 (comment))
joshka pushed a commit to nowNick/ratatui that referenced this pull request May 24, 2024
joshka added a commit to nowNick/ratatui that referenced this pull request May 24, 2024
…rg#1087)

This is a small universal style change to avoid making this change a
part of other PRs.

[rationale](ratatui-org#1083 (comment))
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.

None yet

2 participants