Fix line number rendering.

This commit is contained in:
Blaž Hrastnik 2020-10-04 17:37:28 +09:00
parent 883b77bd24
commit 226fa89d46
2 changed files with 2 additions and 2 deletions

View file

@ -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
}

View file

@ -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,
)
}