From 6d52424303bf92a9abcfe8daa45cff145966f820 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 11 Aug 2021 13:53:38 +0900 Subject: fix: Adjust scroll offset/padding calculation to prevent wobble Fixes #324 --- helix-view/src/view.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'helix-view/src/view.rs') 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 -- cgit v1.2.3-70-g09d2