on master help sign in
Fix last line number being drawn in the status bar.
commit1a9ae72fcb3e566d7a77ee40e009a5070899558e authorNathan Vegdahl <cessen@cessen.com> dateSun 18 Jul 2021, 23:09 (5 years ago) parente462f32
1 file changed+10−1
helix-term/src/ui/editor.rs+10−1
helix-term/src/ui/editor.rs+10−1
@@ -330,7 +330,16 @@ impl EditorView {
330330 // document or not. We only draw it if it's not an empty line.
331331 let draw_last = text.line_to_byte(last_line) < text.len_bytes();
332332
333− for (i, line) in (view.first_line..=last_line).enumerate() {
333+ // This is a little confuding: We can't use the `last_line` variable for
334+ // our iteration below, because there's a mismatch between the
335+ // inclusive/exclusiveness of the screen-based last line and the
336+ // text-based last line. So we compute what we actually need specially here.
337+ let last_line_number = std::cmp::min(
338+ view.first_line + view.area.height.saturating_sub(1) as usize,
339+ doc.text().len_lines(),
340+ );
341+
342+ for (i, line) in (view.first_line..last_line_number).enumerate() {
334343 use helix_core::diagnostic::Severity;
335344 if let Some(diagnostic) = doc.diagnostics().iter().find(|d| d.line == line) {
336345 surface.set_stringn(