fix scroll at 90%: prevent third condition from undoing threshold scroll
This commit is contained in:
parent
b161924bbc
commit
01d2c4f609
1 changed files with 2 additions and 2 deletions
|
|
@ -142,7 +142,7 @@ fn adjust_scroll(input: &str, cursor: usize, scroll: &mut usize, cols: usize) {
|
|||
if cursor < *scroll {
|
||||
*scroll = cursor;
|
||||
}
|
||||
if *scroll + max_visible > nchars {
|
||||
if cursor < *scroll + threshold && *scroll + max_visible > nchars {
|
||||
*scroll = nchars.saturating_sub(max_visible);
|
||||
}
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ fn draw_all(
|
|||
out.push_str("\x1b[K");
|
||||
out.push_str(RESET);
|
||||
|
||||
let cursor_col = prompt.len() + cursor.saturating_sub(scroll);
|
||||
let cursor_col = (prompt.len() + cursor.saturating_sub(scroll)).min(cols - 1);
|
||||
out.push_str(&format!("\x1b[{};{}H", rows, cursor_col + 1));
|
||||
|
||||
let _ = stdout.write_all(out.as_bytes());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue