From 226fa89d461f0a537e2b3fe88a1f8eebad2fdb0d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= <blaz@mxxn.io>
Date: Sun, 4 Oct 2020 17:37:28 +0900
Subject: [PATCH] Fix line number rendering.

---
 helix-term/src/editor.rs | 2 +-
 helix-view/src/view.rs   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/helix-term/src/editor.rs b/helix-term/src/editor.rs
index 4386834a..a348aa6e 100644
--- a/helix-term/src/editor.rs
+++ b/helix-term/src/editor.rs
@@ -221,7 +221,7 @@ impl Editor {
                 let style: Style = view.theme.get("ui.linenr");
                 for (i, line) in (view.first_line..(last_line as u16)).enumerate() {
                     self.surface
-                        .set_stringn(0, line, format!("{:>5}", i + 1), 5, style);
+                        .set_stringn(0, i as u16, format!("{:>5}", line + 1), 5, style);
                     // lavender
                 }
 
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index ac342d61..09cd4c65 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -53,7 +53,7 @@ impl View {
     #[inline]
     pub fn last_line(&self, viewport: Rect) -> usize {
         std::cmp::min(
-            (self.first_line + viewport.height - 1) as usize,
+            (self.first_line + viewport.height) as usize,
             self.state.doc().len_lines() - 1,
         )
     }