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

fix(paragraph): Account for Block in Paragraphs line_width, and line_count methods. #1235

Merged
merged 1 commit into from
Jul 23, 2024
Merged

Conversation

airblast-dev
Copy link
Contributor

@airblast-dev airblast-dev commented Jul 22, 2024

Fixes: #1233

The line_width, and line_count methods for Paragraph would not take into account the Block if one was set. This will now correctly calculate the values including the Block's width/height.

The Blocks newly implemented horizontal_space, and vertical_space can also be used in Block::inner since its mostly duplicate logic. Can add it to this PR or a separate one later. This is also why I decided it would be better to return the results as (top, bottom), and (left, right) since it would allow for use in more areas.

Copy link

codecov bot commented Jul 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.5%. Comparing base (c34fb77) to head (b8e23bd).

Additional details and impacted files
@@          Coverage Diff           @@
##            main   #1235    +/-   ##
======================================
  Coverage   94.5%   94.5%            
======================================
  Files         65      65            
  Lines      15136   15276   +140     
======================================
+ Hits       14305   14445   +140     
  Misses       831     831            

☔ 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.

LGTM - nothing major to be changed. Just some small subjective tidy ups that I'd happily merge without fixing

src/widgets/block.rs Outdated Show resolved Hide resolved
src/widgets/block.rs Outdated Show resolved Hide resolved
src/widgets/block.rs Outdated Show resolved Hide resolved
src/widgets/block.rs Outdated Show resolved Hide resolved
src/widgets/paragraph.rs Show resolved Hide resolved
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.

checks are breaking

@airblast-dev
Copy link
Contributor Author

I accidentally merged instead of rebasing and made a mess. There is also a missing semi-colon in one of the suggestions. Will clean up things locally and do a push.

@airblast-dev
Copy link
Contributor Author

Things should be fixed now. Applied the suggestions, and made a few syntax fixes. I think this is good to go.

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 great!. Thanks for your contribution :)

@joshka joshka merged commit 03f3124 into ratatui:main Jul 23, 2024
33 checks passed
joshka pushed a commit to erak/ratatui that referenced this pull request Oct 14, 2024
…atui#1235)

The `line_width`, and `line_count` methods for `Paragraph` would not
take into account the `Block` if one was set. This will now correctly
calculate the values including the `Block`'s width/height.

Fixes: ratatui#1233
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.

Paragraph::line_count and line_width don't take block borders into account
2 participants