forge
Explore
Log in

Don't you dare go Hollow

Preserve empty named workspaces upon output removal

Browse files at this commit

b5ad0e12fd46f7ab06f4bbc0e80bf3f2d4395cbfIvan MolodetskikhParent: c8e46b9
Not sure how we missed this.
src/layout/mod.rsmodified+28 -1
@@ -403,7 +403,7 @@ impl<W: LayoutElement> Layout<W> {
403403 }
404404
405405 // Get rid of empty workspaces.
406- workspaces.retain(|ws| ws.has_windows());
406+ workspaces.retain(|ws| ws.has_windows() || ws.name.is_some());
407407
408408 if monitors.is_empty() {
409409 // Removed the last monitor.
@@ -3811,6 +3811,33 @@ mod tests {
38113811 check_ops(&ops);
38123812 }
38133813
3814+ #[test]
3815+ fn removing_all_outputs_preserves_empty_named_workspaces() {
3816+ let ops = [
3817+ Op::AddOutput(1),
3818+ Op::AddNamedWorkspace {
3819+ ws_name: 1,
3820+ output_name: None,
3821+ },
3822+ Op::AddNamedWorkspace {
3823+ ws_name: 2,
3824+ output_name: None,
3825+ },
3826+ Op::RemoveOutput(1),
3827+ ];
3828+
3829+ let mut layout = Layout::default();
3830+ for op in ops {
3831+ op.apply(&mut layout);
3832+ }
3833+
3834+ let MonitorSet::NoOutputs { workspaces } = layout.monitor_set else {
3835+ unreachable!()
3836+ };
3837+
3838+ assert_eq!(workspaces.len(), 2);
3839+ }
3840+
38143841 fn arbitrary_spacing() -> impl Strategy<Value = u16> {
38153842 // Give equal weight to:
38163843 // - 0: the element is disabled