Skip to content

Commit c5b4084

Browse files
authored
Merge pull request console-rs#282 from tbergerd/dev
fix console-rs#281 : Select : prompt is no longer displayed
2 parents 7aa4afa + 339693b commit c5b4084

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/paging.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ impl<'a> Paging<'a> {
4242
}
4343
}
4444

45+
pub fn update_page(&mut self, cursor_pos: usize) {
46+
if cursor_pos != !0
47+
&& (cursor_pos < self.current_page * self.capacity
48+
|| cursor_pos >= (self.current_page + 1) * self.capacity)
49+
{
50+
self.current_page = cursor_pos / self.capacity;
51+
}
52+
}
53+
4554
/// Updates all internal based on the current terminal size and cursor position
4655
pub fn update(&mut self, cursor_pos: usize) -> Result {
4756
let new_term_size = self.term.size();
@@ -65,12 +74,7 @@ impl<'a> Paging<'a> {
6574
self.term.clear_last_lines(self.capacity)?;
6675
}
6776

68-
if cursor_pos != !0
69-
&& (cursor_pos < self.current_page * self.capacity
70-
|| cursor_pos >= (self.current_page + 1) * self.capacity)
71-
{
72-
self.current_page = cursor_pos / self.capacity;
73-
}
77+
self.update_page(cursor_pos);
7478

7579
Ok(())
7680
}

src/prompts/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl Select<'_> {
214214
}
215215

216216
term.hide_cursor()?;
217-
paging.update(sel)?;
217+
paging.update_page(sel);
218218

219219
loop {
220220
if let Some(ref prompt) = self.prompt {

0 commit comments

Comments
 (0)