forge
Explore
Log in

Don't you dare go Hollow

Fix panic when the last window on previous workspace is closed

Browse files at this commit

d3735227cec6439d36cd2f6061df5dbc7cc9bc19Ivan MolodetskikhParent: 5ad5f29
src/layout.rsmodified+20 -0
@@ -528,6 +528,10 @@ impl<W: LayoutElement> MonitorSet<W> {
528 && idx != mon.workspaces.len() - 1528 && idx != mon.workspaces.len() - 1
529 {529 {
530 mon.workspaces.remove(idx);530 mon.workspaces.remove(idx);
531+
532+ if idx < mon.active_workspace_idx {
533+ mon.active_workspace_idx -= 1;
534+ }
531 }535 }
532 536
533 break;537 break;
@@ -2612,4 +2616,20 @@ mod tests {
2612 2616
2613 check_ops(&ops);2617 check_ops(&ops);
2614 }2618 }
2619+
2620+ #[test]
2621+ fn test() {
2622+ let ops = [
2623+ Op::AddOutput(1),
2624+ Op::AddWindow {
2625+ id: 0,
2626+ bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)),
2627+ activate: true,
2628+ },
2629+ Op::FocusWorkspaceDown,
2630+ Op::CloseWindow(0),
2631+ ];
2632+
2633+ check_ops(&ops);
2634+ }
2615 }2635 }