Skip to content

Commit

Permalink
Fix regression on Select which hides the prompt if there is only one …
Browse files Browse the repository at this point in the history
…page
  • Loading branch information
tbergerd committed Sep 21, 2023
1 parent 9c3185c commit 070000e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/paging.rs
Expand Up @@ -42,6 +42,16 @@ impl<'a> Paging<'a> {
}
}

pub fn update_page(&mut self, cursor_pos: usize) {
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 +75,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
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

0 comments on commit 070000e

Please sign in to comment.