Skip to content

Commit

Permalink
Merge pull request #282 from tbergerd/dev
Browse files Browse the repository at this point in the history
fix #281 : Select : prompt is no longer displayed
  • Loading branch information
pksunkara authored Sep 21, 2023
2 parents 7aa4afa + 339693b commit c5b4084
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
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) {
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

0 comments on commit c5b4084

Please sign in to comment.