diff options
author | Nathan Vegdahl | 2021-07-19 06:09:55 +0000 |
---|---|---|
committer | Nathan Vegdahl | 2021-07-19 06:09:55 +0000 |
commit | 1a9ae72fcb3e566d7a77ee40e009a5070899558e (patch) | |
tree | 808edaa991e8bf061ea57bc0450deaabd7956905 /helix-term | |
parent | e462f32723bb61899a390f438d7d856d87fb7614 (diff) |
Fix last line number being drawn in the status bar.
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/ui/editor.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 40b57b85..769771af 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -330,7 +330,16 @@ impl EditorView { // document or not. We only draw it if it's not an empty line. let draw_last = text.line_to_byte(last_line) < text.len_bytes(); - for (i, line) in (view.first_line..=last_line).enumerate() { + // This is a little confuding: We can't use the `last_line` variable for + // our iteration below, because there's a mismatch between the + // inclusive/exclusiveness of the screen-based last line and the + // text-based last line. So we compute what we actually need specially here. + let last_line_number = std::cmp::min( + view.first_line + view.area.height.saturating_sub(1) as usize, + doc.text().len_lines(), + ); + + for (i, line) in (view.first_line..last_line_number).enumerate() { use helix_core::diagnostic::Severity; if let Some(diagnostic) = doc.diagnostics().iter().find(|d| d.line == line) { surface.set_stringn( |