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.

Activate last item if item's number is greater than the last one's (#31471)

Kirill Bulatovfe0bcd14d2f6
diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs
index ad3eff848a0..948ef024640 100644
--- a/crates/workspace/src/pane.rs
+++ b/crates/workspace/src/pane.rs
@@ -3249,12 +3249,18 @@ impl Render for Pane {
.on_action(cx.listener(Pane::toggle_zoom))
.on_action(
cx.listener(|pane: &mut Pane, action: &ActivateItem, window, cx| {
- pane.activate_item(action.0, true, true, window, cx);
+ pane.activate_item(
+ action.0.min(pane.items.len().saturating_sub(1)),
+ true,
+ true,
+ window,
+ cx,
+ );
}),
)
.on_action(
cx.listener(|pane: &mut Pane, _: &ActivateLastItem, window, cx| {
- pane.activate_item(pane.items.len() - 1, true, true, window, cx);
+ pane.activate_item(pane.items.len().saturating_sub(1), true, true, window, cx);
}),
)
.on_action(