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 #281 : Select : prompt is no longer displayed #282

Merged
merged 3 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ impl<'a> Paging<'a> {
}
}

pub fn update_page(&mut self, cursor_pos: usize) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note : I marked it pub for consistency, otherwise I'd have made it pub(crate). Doesn't matter here because module is private.

if cursor_pos != !0
&& (cursor_pos < self.current_page * self.capacity
|| cursor_pos >= (self.current_page + 1) * self.capacity)
{
self.current_page = cursor_pos / self.capacity;
}
}

/// Updates all internal based on the current terminal size and cursor position
pub fn update(&mut self, cursor_pos: usize) -> Result {
let new_term_size = self.term.size();
Expand All @@ -65,12 +74,7 @@ impl<'a> Paging<'a> {
self.term.clear_last_lines(self.capacity)?;
}

if cursor_pos != !0
&& (cursor_pos < self.current_page * self.capacity
|| cursor_pos >= (self.current_page + 1) * self.capacity)
{
self.current_page = cursor_pos / self.capacity;
}
self.update_page(cursor_pos);

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/prompts/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl Select<'_> {
}

term.hide_cursor()?;
paging.update(sel)?;
paging.update_page(sel);

loop {
if let Some(ref prompt) = self.prompt {
Expand Down