aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-08-11 04:53:38 +0000
committerBlaž Hrastnik2021-08-11 04:53:38 +0000
commit6d52424303bf92a9abcfe8daa45cff145966f820 (patch)
tree7396a9f8da114086e9daa3898c4cf78b0d8e7d85 /helix-view/src
parent55f1f04717f4f1a657c1f68123af245a7d069eef (diff)
fix: Adjust scroll offset/padding calculation to prevent wobble
Fixes #324
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/view.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index 25efbde5..265f7df8 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -93,7 +93,10 @@ impl View {
let height = self.area.height.saturating_sub(1); // - 1 for statusline
let last_line = (self.first_line + height as usize).saturating_sub(1);
- let scrolloff = scrolloff.min(self.area.height as usize / 2);
+ // - 1 so we have at least one gap in the middle.
+ // a height of 6 with padding of 3 on each side will keep shifting the view back and forth
+ // as we type
+ let scrolloff = scrolloff.min(height.saturating_sub(1) as usize / 2);
// TODO: not ideal
const OFFSET: usize = 7; // 1 diagnostic + 5 linenr + 1 gutter