vim: Fix ctrl-u/ctrl-d

They should work by exactly half a screen, and also move the cursor.
This commit is contained in:
Conrad Irwin
2023-09-26 22:28:04 -06:00
parent 342a00b89e
commit 8e1bbf32be
5 changed files with 122 additions and 21 deletions
+7 -3
View File
@@ -15,9 +15,13 @@ impl ScrollAmount {
Self::Line(count) => *count,
Self::Page(count) => editor
.visible_line_count()
// subtract one to leave an anchor line
// round towards zero (so page-up and page-down are symmetric)
.map(|l| (l * count).trunc() - count.signum())
.map(|mut l| {
// for full pages subtract one to leave an anchor line
if count.abs() == 1.0 {
l -= 1.0
}
(l * count).trunc()
})
.unwrap_or(0.),
}
}