tui-widgets
tui-widgets copied to clipboard
feat: Query if ScrollViewState is_at_bottom()
Hey 🐅,
this aims to fix #72
It is close to what was discussed but I made the additional decision to respect the page size. I believe this is the right way to do it as not respecting the page size feels very odd to the user, example:
let state = ...;
// our content is 5 rows
assert_eq!(state.size.unwrap().height, 5);
// our page size is 3
assert_eq!(state.page_size.unwrap().height, 3);
// Scrolling down 5 times
state.scroll_down();
state.scroll_down();
state.scroll_down();
state.scroll_down();
state.scroll_down();
// Render it
scroll_view.render(...);
// Are we at the bottom?
assert!(state.is_at_bottom()); // FAILS!
// This is because rendering resets our offset to cater for the page size
assert_eq!(state.offset.unwrap().y, 2);
See scroll_view.rs:210-232 for why that is.
Since that felt wrong to me, I made the judgment call for is_at_bottom() to consider the page size. So technically it is now a are_we_scrolled_down_enough_so_it_behaves_and_looks_like_we_are_at_the_bottom() 🥸
I added a unit test.
Feedback? :)
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 74.36%. Comparing base (
59a01f7) to head (cbfbe82).
Additional details and impacted files
@@ Coverage Diff @@
## main #75 +/- ##
==========================================
+ Coverage 73.90% 74.36% +0.46%
==========================================
Files 16 16
Lines 2667 2672 +5
==========================================
+ Hits 1971 1987 +16
+ Misses 696 685 -11
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@joshka any actions required from my side? If not, just slam an emoji on my message and I will know you are just busy.