simplify scroll to bash-like: cursor always at far right, no jump at 90%
This commit is contained in:
parent
01d2c4f609
commit
b6f1850a24
1 changed files with 3 additions and 4 deletions
|
|
@ -133,16 +133,15 @@ fn adjust_scroll(input: &str, cursor: usize, scroll: &mut usize, cols: usize) {
|
|||
if max_visible == 0 {
|
||||
return;
|
||||
}
|
||||
let threshold = (max_visible as f64 * 0.9) as usize;
|
||||
let nchars = input.chars().count();
|
||||
|
||||
if cursor > *scroll + threshold {
|
||||
*scroll = cursor - threshold;
|
||||
if cursor >= *scroll + max_visible {
|
||||
*scroll = cursor + 1 - max_visible;
|
||||
}
|
||||
if cursor < *scroll {
|
||||
*scroll = cursor;
|
||||
}
|
||||
if cursor < *scroll + threshold && *scroll + max_visible > nchars {
|
||||
if *scroll + max_visible > nchars {
|
||||
*scroll = nchars.saturating_sub(max_visible);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue