Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove any empty workspaces after move-workspace command #743

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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