Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

editor: Fix calculate relative line number panic (#41352)

Anthony Eid2b5699117f22
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index d6e85631fd1..fd4795f40ff 100644
--- a/crates/editor/src/element.rs
+++ b/crates/editor/src/element.rs
@@ -3181,7 +3181,7 @@ impl EditorElement {
i += 1;
}
delta = 1;
- i = head_idx.min(buffer_rows.len() as u32 - 1);
+ i = head_idx.min(buffer_rows.len().saturating_sub(1) as u32);
while i > 0 && buffer_rows[i as usize].buffer_row.is_none() && !count_wrapped_lines {
i -= 1;
}