mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
vim: Fix panic due to overflow when scrolling (#16029)
When setting `"vertical_scroll_margin": 99` or other high values this can lead to a panic that crashes Zed. Release Notes: - vim: Fixed a possible panic that could happen when using a very high value for `vertical_scroll_margin` that exceeded the number of visible lines on the screen. Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
parent
19d8422933
commit
09c9ed4765
@ -111,7 +111,10 @@ fn scroll_editor(
|
|||||||
DisplayRow(top.row().0 + vertical_scroll_margin as u32)
|
DisplayRow(top.row().0 + vertical_scroll_margin as u32)
|
||||||
};
|
};
|
||||||
let max_row = DisplayRow(
|
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 {
|
let new_head = if head.row() < min_row {
|
||||||
|
Loading…
Reference in New Issue
Block a user