fix scroll at 90%: prevent third condition from undoing threshold scroll

This commit is contained in:
Niko Marmeladkov 2026-07-15 22:26:51 +03:00
parent b161924bbc
commit 01d2c4f609
Signed by untrusted user who does not match committer: Niko
GPG key ID: E3B955F9442D44E3

View file

@ -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());