Skip to content

Commit

Permalink
fix: remove empty workspaces after move
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger committed Sep 28, 2024
1 parent ac370d7 commit d41dd16
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Context;

use super::{activate_workspace, sort_workspaces};
use super::{activate_workspace, deactivate_workspace, sort_workspaces};
use crate::{
common::Direction,
containers::{
Expand Down Expand Up @@ -60,6 +60,19 @@ pub fn move_workspace_in_direction(
activate_workspace(None, Some(monitor), state, config)?;
}

// Get empty workspace to destroy (if one is found). Cannot destroy
// empty workspaces if they're the only workspace on the monitor.
let workspace_to_destroy =
state.workspaces().into_iter().find(|workspace| {
!workspace.config().keep_alive
&& !workspace.has_children()
&& !workspace.is_displayed()
});

if let Some(workspace) = workspace_to_destroy {
deactivate_workspace(workspace, state)?;
}

sort_workspaces(target_monitor, config)?;

state.emit_event(WmEvent::WorkspaceUpdated {
Expand Down

0 comments on commit d41dd16

Please sign in to comment.