Skip to content

Commit

Permalink
fix: remove any empty workspaces after move-workspace command (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger authored Sep 29, 2024
1 parent ac370d7 commit f7ece4c
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 f7ece4c

Please sign in to comment.