diff options
author | Brian Ashworth <[email protected]> | 2019-06-05 01:31:50 -0400 |
---|---|---|
committer | Drew DeVault <[email protected]> | 2019-06-05 11:02:35 -0400 |
commit | f0f5de9a9e87ca1f0d74e7cbf82ffceba51ffbe6 (patch) | |
tree | 396dc81beb04174d2b8bab75d07294c991d95d3c /sway/commands.c | |
parent | 190546fd315a24c04006fb1b177069933f4350da (diff) |
criteria: reset on semicolon separation
This matches i3's behavior of only retaining criteria across comma
separated commands. When separating commands with a semicolon, the
criteria is reset and allows for new criteria to be set, if desired.
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/sway/commands.c b/sway/commands.c index 237bfc28..377f2d01 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -227,28 +227,31 @@ list_t *execute_command(char *_exec, struct sway_seat *seat, head = exec; do { - // Extract criteria (valid for this command list only). - config->handler_context.using_criteria = false; - if (*head == '[') { - char *error = NULL; - struct criteria *criteria = criteria_parse(head, &error); - if (!criteria) { - list_add(res_list, cmd_results_new(CMD_INVALID, "%s", error)); - free(error); - goto cleanup; - } - views = criteria_get_views(criteria); - head += strlen(criteria->raw); - criteria_destroy(criteria); - config->handler_context.using_criteria = true; - // Skip leading whitespace - for (; isspace(*head); ++head) {} - } // Split command list cmdlist = argsep(&head, ";"); - for (; isspace(*cmdlist); ++cmdlist) {} do { - // Split commands + // Skip leading whitespace + for (; isspace(*cmdlist); ++cmdlist) {} + // Extract criteria (valid for this command chain only). + config->handler_context.using_criteria = false; + if (*cmdlist == '[') { + char *error = NULL; + struct criteria *criteria = criteria_parse(cmdlist, &error); + if (!criteria) { + list_add(res_list, + cmd_results_new(CMD_INVALID, "%s", error)); + free(error); + goto cleanup; + } + list_free(views); + views = criteria_get_views(criteria); + cmdlist += strlen(criteria->raw); + criteria_destroy(criteria); + config->handler_context.using_criteria = true; + // Skip leading whitespace + for (; isspace(*cmdlist); ++cmdlist) {} + } + // Split command chain into commands cmd = argsep(&cmdlist, ","); for (; isspace(*cmd); ++cmd) {} if (strcmp(cmd, "") == 0) { |