Skip to content

Commit

Permalink
Merge pull request #4698 from orestisfl/user_output_names_find_next
Browse files Browse the repository at this point in the history
user_output_names_find_next: Always initialize target_output
  • Loading branch information
Airblader authored Nov 27, 2021
2 parents d44e144 + 854616e commit 298c3ae
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions release-notes/bugfixes/4-failed-workspace-output
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix wrong failed reply on move workspace to output
16 changes: 8 additions & 8 deletions src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,14 @@ static Output *user_output_names_find_next(user_output_names_head *names, Output
Output *target_output = NULL;
user_output_name *uo;
TAILQ_FOREACH (uo, names, user_output_names) {
if (!target_output) {
/* The first available output from the list is used in 2 cases:
* 1. When we must wrap around the user list. For example, if user
* specifies outputs A B C and C is `current_output`.
* 2. When the current output is not in the user list. For example,
* user specifies A B C and D is `current_output`. */
target_output = get_output_from_string(current_output, uo->name);
}
if (strcasecmp(output_primary_name(current_output), uo->name) == 0) {
/* The current output is in the user list */
while (true) {
Expand All @@ -1071,14 +1079,6 @@ static Output *user_output_names_find_next(user_output_names_head *names, Output
}
break;
}
if (!target_output) {
/* The first available output from the list is used in 2 cases:
* 1. When we must wrap around the user list. For example, if user
* specifies outputs A B C and C is `current_output`.
* 2. When the current output is not in the user list. For example,
* user specifies A B C and D is `current_output`. */
target_output = get_output_from_string(current_output, uo->name);
}
}
return target_output;
}
Expand Down
10 changes: 10 additions & 0 deletions testcases/t/543-move-workspace-to-multiple-outputs.t
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ sub is_ws {
is(get_output_for_workspace("$ws_num"), "fake-$out_num", "Workspace $ws_num -> $out_num: $msg");
}

###############################################################################
# Test moving workspace to same output
# See issue #4691
###############################################################################
is_ws(1, 0, 'sanity check');

my $reply = cmd '[con_mark=aa] move workspace to output fake-0';
is_ws(1, 0, 'workspace did not move');
ok($reply->[0]->{success}, 'reply success');

###############################################################################
# Test using "next" special keyword
###############################################################################
Expand Down

0 comments on commit 298c3ae

Please sign in to comment.