From ff73ddeeee71571e2f40fa3be430ef83cd13b15e Mon Sep 17 00:00:00 2001 From: Albert Safin Date: Mon, 23 Sep 2019 08:13:05 +0000 Subject: [PATCH] extract_workspace_names_from_bindings: handle optional flags fixes #3527 --- src/workspace.c | 15 ++++++++++++--- testcases/t/172-start-on-named-ws.t | 18 ++++++++++++++++++ testcases/t/270-config-no-newline-end.t | 3 +-- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/workspace.c b/src/workspace.c index 4f618751..4a1c4de8 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -197,18 +197,27 @@ void extract_workspace_names_from_bindings(void) { while (*target == ' ' || *target == '\t') target++; /* We check if this is the workspace - * next/prev/next_on_output/prev_on_output/back_and_forth/number command. + * next/prev/next_on_output/prev_on_output/back_and_forth command. * Beware: The workspace names "next", "prev", "next_on_output", - * "prev_on_output", "number", "back_and_forth" and "current" are OK, + * "prev_on_output", "back_and_forth" and "current" are OK, * so we check before stripping the double quotes */ if (strncasecmp(target, "next", strlen("next")) == 0 || strncasecmp(target, "prev", strlen("prev")) == 0 || strncasecmp(target, "next_on_output", strlen("next_on_output")) == 0 || strncasecmp(target, "prev_on_output", strlen("prev_on_output")) == 0 || - strncasecmp(target, "number", strlen("number")) == 0 || strncasecmp(target, "back_and_forth", strlen("back_and_forth")) == 0 || strncasecmp(target, "current", strlen("current")) == 0) continue; + if (strncasecmp(target, "--no-auto-back-and-forth", strlen("--no-auto-back-and-forth")) == 0) { + target += strlen("--no-auto-back-and-forth"); + while (*target == ' ' || *target == '\t') + target++; + } + if (strncasecmp(target, "number", strlen("number")) == 0) { + target += strlen("number"); + while (*target == ' ' || *target == '\t') + target++; + } char *target_name = parse_string(&target, false); if (target_name == NULL) continue; diff --git a/testcases/t/172-start-on-named-ws.t b/testcases/t/172-start-on-named-ws.t index 778eb23b..d1af6c07 100644 --- a/testcases/t/172-start-on-named-ws.t +++ b/testcases/t/172-start-on-named-ws.t @@ -125,4 +125,22 @@ is_deeply(\@names, [ '3' ], 'i3 starts on workspace 3'); exit_gracefully($pid); +############################################################## +# 7: verify optional flags do not affect startup workspace +############################################################## + +$config = < 0; my $first_lines = <<'EOT'; -set $workspace1 workspace number 1 set $workspace0 workspace eggs -bindsym Mod4+1 $workspace1 +font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 EOT # Intentionally don't add a trailing newline for the last line since this is