Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3815 from xzfc/3694-baf-rename
Browse files Browse the repository at this point in the history
When renaming a workspace, update the previous_workspace_name too
  • Loading branch information
orestisfl committed Oct 9, 2019
2 parents ea216f8 + 7e4eb51 commit 5e1094e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/commands.c
Expand Up @@ -2013,6 +2013,13 @@ void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name) {
con_focus(previously_focused);
}

/* Let back-and-forth work after renaming the previous workspace.
* See #3694. */
if (previous_workspace_name && !strcmp(previous_workspace_name, old_name_copy)) {
FREE(previous_workspace_name);
previous_workspace_name = sstrdup(new_name);
}

cmd_output->needs_tree_render = true;
ysuccess(true);

Expand Down
47 changes: 47 additions & 0 deletions testcases/t/176-workspace-baf.t
Expand Up @@ -171,6 +171,53 @@ cmd 'restart';
cmd 'workspace back_and_forth';
is(focused_ws, '5: foo', 'workspace 5 focused after restart');

################################################################################
# Check BAF switching to renamed workspace.
# Issue: #3694
################################################################################

kill_all_windows;
cmd 'workspace --no-auto-back-and-forth 1';
open_window;
cmd 'workspace --no-auto-back-and-forth 2';

cmd 'rename workspace 1 to 3';
cmd 'workspace back_and_forth';
is(focused_ws, '3', 'workspace 3 focused after rename');

################################################################################
# Check BAF switching to renamed and then closed workspace.
# Issue: #3694
################################################################################

kill_all_windows;
cmd 'workspace --no-auto-back-and-forth 1';
$first_win = open_window;
cmd 'workspace --no-auto-back-and-forth 2';

cmd 'rename workspace 1 to 3';
cmd '[id="' . $first_win->id . '"] kill';

cmd 'workspace back_and_forth';
is(focused_ws, '3', 'workspace 3 focused after renaming and destroying');

################################################################################
# See if renaming current workspace doesn't affect BAF switching to another
# renamed workspace.
# Issue: #3694
################################################################################

kill_all_windows;
cmd 'workspace --no-auto-back-and-forth 1';
$first_win = open_window;
cmd 'workspace --no-auto-back-and-forth 2';

cmd 'rename workspace 1 to 3';
cmd 'rename workspace 2 to 4';

cmd 'workspace back_and_forth';
is(focused_ws, '3', 'workspace 3 focused after renaming');

exit_gracefully($pid);

done_testing;

0 comments on commit 5e1094e

Please sign in to comment.