diff options
author | Nathan Vegdahl | 2021-07-19 15:39:48 +0000 |
---|---|---|
committer | Nathan Vegdahl | 2021-07-19 15:39:48 +0000 |
commit | 079d4ed86df30c78ca00fd4b86f906c3ea9df7db (patch) | |
tree | a2a9b448ceb109cdfe66fe8ec5a7714f06415a19 /helix-view/src/view.rs | |
parent | 1a9ae72fcb3e566d7a77ee40e009a5070899558e (diff) |
Properly fix `last_line` view calculation.
Turned out to be simpler than I thought. Didn't even need to change the
other use-sites.
Diffstat (limited to 'helix-view/src/view.rs')
-rw-r--r-- | helix-view/src/view.rs | 5 |
1 files changed, 3 insertions, 2 deletions
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), ) } |