Ensure pane: swap item right does not panic (#36765)

This fixes a panic I randomly ran into whilst mistyping in the command
palette: I accidentally ran `pane: swap item right`in a state where no
items were opened in my active pane. We were checking for `index + 1 ==
self.items.len()` there when it really should be `>=`, as otherwise in
the case of no items this panics.

This PR fixes the bug, adds a test for both the panic as well as the
actions themselves (they were untested previously). Lastly (and mostly),
this also cleans up a bit around existing actions to update them with
how we generally handle actions now.

Release Notes:

- Fixed a panic that could occur with the `pane: swap item right`
action.
This commit is contained in:
Finn Evers 2025-08-22 23:28:55 +02:00 committed by GitHub
parent f649c31bf9
commit e6267c42f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 110 additions and 57 deletions

View file

@ -970,7 +970,7 @@ async fn test_peers_following_each_other(cx_a: &mut TestAppContext, cx_b: &mut T
// the follow.
workspace_b.update_in(cx_b, |workspace, window, cx| {
workspace.active_pane().update(cx, |pane, cx| {
pane.activate_prev_item(true, window, cx);
pane.activate_previous_item(&Default::default(), window, cx);
});
});
executor.run_until_parked();
@ -1073,7 +1073,7 @@ async fn test_peers_following_each_other(cx_a: &mut TestAppContext, cx_b: &mut T
// Client A cycles through some tabs.
workspace_a.update_in(cx_a, |workspace, window, cx| {
workspace.active_pane().update(cx, |pane, cx| {
pane.activate_prev_item(true, window, cx);
pane.activate_previous_item(&Default::default(), window, cx);
});
});
executor.run_until_parked();
@ -1117,7 +1117,7 @@ async fn test_peers_following_each_other(cx_a: &mut TestAppContext, cx_b: &mut T
workspace_a.update_in(cx_a, |workspace, window, cx| {
workspace.active_pane().update(cx, |pane, cx| {
pane.activate_prev_item(true, window, cx);
pane.activate_previous_item(&Default::default(), window, cx);
});
});
executor.run_until_parked();
@ -1164,7 +1164,7 @@ async fn test_peers_following_each_other(cx_a: &mut TestAppContext, cx_b: &mut T
workspace_a.update_in(cx_a, |workspace, window, cx| {
workspace.active_pane().update(cx, |pane, cx| {
pane.activate_prev_item(true, window, cx);
pane.activate_previous_item(&Default::default(), window, cx);
});
});
executor.run_until_parked();