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.

vim: Fix panic due to overflow when scrolling (#16029)

Thorsten Ball09c9ed4765e5
diff --git a/crates/vim/src/normal/scroll.rs b/crates/vim/src/normal/scroll.rs
index b01b287f210..68dda5711bd 100644
--- a/crates/vim/src/normal/scroll.rs
+++ b/crates/vim/src/normal/scroll.rs
@@ -111,7 +111,10 @@ fn scroll_editor(
DisplayRow(top.row().0 + vertical_scroll_margin as u32)
};
let max_row = DisplayRow(
- top.row().0 + visible_line_count as u32 - vertical_scroll_margin as u32 - 1,
+ top.row().0
+ + (visible_line_count as u32)
+ .saturating_sub(vertical_scroll_margin as u32)
+ .saturating_sub(1),
);
let new_head = if head.row() < min_row {