aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-19 15:39:48 +0000
committerNathan Vegdahl2021-07-19 15:39:48 +0000
commit079d4ed86df30c78ca00fd4b86f906c3ea9df7db (patch)
treea2a9b448ceb109cdfe66fe8ec5a7714f06415a19 /helix-view/src
parent1a9ae72fcb3e566d7a77ee40e009a5070899558e (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')
-rw-r--r--helix-view/src/view.rs5
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),
)
}