From 6846ac98c0a3c4f179d65b51f9481d7f77625c55 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Thu, 6 Sep 2018 03:11:47 +0300 Subject: [PATCH] cmd_rename_workspace: correct order of events 1. Rename happens 2. Workspace is moved because of assignments 3. Workspace closes because it is empty (#3248) Fixes #3248. --- src/commands.c | 2 +- testcases/t/522-rename-assigned-workspace.t | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/commands.c b/src/commands.c index 0343f9dc..33743848 100644 --- a/src/commands.c +++ b/src/commands.c @@ -2002,6 +2002,7 @@ void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name) { Con *parent = workspace->parent; con_detach(workspace); con_attach(workspace, parent, false); + ipc_send_workspace_event("rename", workspace, NULL); /* Move the workspace to the correct output if it has an assignment */ struct Workspace_Assignment *assignment = NULL; @@ -2046,7 +2047,6 @@ void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name) { cmd_output->needs_tree_render = true; ysuccess(true); - ipc_send_workspace_event("rename", workspace, NULL); ewmh_update_desktop_names(); ewmh_update_desktop_viewport(); ewmh_update_current_desktop(); diff --git a/testcases/t/522-rename-assigned-workspace.t b/testcases/t/522-rename-assigned-workspace.t index af3b3262..9897e4ee 100644 --- a/testcases/t/522-rename-assigned-workspace.t +++ b/testcases/t/522-rename-assigned-workspace.t @@ -93,6 +93,21 @@ cmd 'rename workspace 5 to 2'; is(get_output_for_workspace('2'), 'fake-1', 'Renaming an unfocused workspace, triggering an assignment to the output which holds the currently focused empty workspace should result in the original workspace replacing the empty one'); +########################################################################## +# Renaming an unfocused empty workspace, triggering an assignment to the +# output which holds the currently focused non-empty workspace should +# close the empty workspace and not crash i3. +# See issue #3248. +########################################################################## + +cmd 'workspace 1'; +cmd 'workspace 2'; +open_window; +cmd 'rename workspace 1 to baz'; +is(get_output_for_workspace('baz'), '', + 'Renaming an unfocused empty workspace, triggering an assignment to the output which holds the currently focused non-empty workspace should close the empty workspace and not crash i3'); +kill_all_windows; + ########################################################################## # Renaming a workspace with multiple assignments, where the first output # doesn't exist. -- 2.39.5