From 079d4ed86df30c78ca00fd4b86f906c3ea9df7db Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Mon, 19 Jul 2021 08:39:48 -0700 Subject: Properly fix `last_line` view calculation. Turned out to be simpler than I thought. Didn't even need to change the other use-sites. --- helix-view/src/view.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'helix-view') diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs index 24df7a4f..ccb61646 100644 --- a/helix-view/src/view.rs +++ b/helix-view/src/view.rs @@ -119,8 +119,9 @@ impl View { pub fn last_line(&self, doc: &Document) -> usize { let height = self.area.height.saturating_sub(1); // - 1 for statusline std::cmp::min( - self.first_line + height as usize, - doc.text().len_lines() - 1, + // Saturating subs to make it inclusive zero indexing. + (self.first_line + height as usize).saturating_sub(1), + doc.text().len_lines().saturating_sub(1), ) } -- cgit v1.2.3-70-g09d2