From 26c8cbb961b96917b02440b4df6066d8429a8043 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 19 Jan 2024 20:24:18 +0400 Subject: layout: Fix crash due to workspace cleanup during switch --- src/layout/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/layout/mod.rs') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index be1ed6b5..4ea806d8 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -542,6 +542,7 @@ impl Layout { if !ws.has_windows() && idx != mon.active_workspace_idx && idx != mon.workspaces.len() - 1 + && mon.workspace_switch.is_none() { mon.workspaces.remove(idx); @@ -2286,6 +2287,22 @@ mod tests { check_ops_with_options(options, &ops); } + #[test] + fn workspace_cleanup_during_switch() { + let ops = [ + Op::AddOutput(1), + Op::AddWindow { + id: 1, + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), + min_max_size: (Size::from((0, 0)), Size::from((i32::MAX, i32::MAX))), + }, + Op::FocusWorkspaceDown, + Op::CloseWindow(1), + ]; + + check_ops(&ops); + } + fn arbitrary_spacing() -> impl Strategy { // Give equal weight to: // - 0: the element is disabled -- cgit