also handle quoted workspace names, extend t/72 for that

This commit is contained in:
Michael Stapelberg 2011-08-03 03:33:12 +02:00
parent 0092b245a1
commit dcba8024de
2 changed files with 26 additions and 4 deletions

View File

@ -378,8 +378,13 @@ void init_ws_for_output(Output *output, Con *content) {
strncasecmp(bind->command, "workspace", strlen("workspace")) != 0) strncasecmp(bind->command, "workspace", strlen("workspace")) != 0)
continue; continue;
DLOG("relevant command = %s\n", bind->command); DLOG("relevant command = %s\n", bind->command);
char *target = bind->command + strlen("workspace ");
if (*target == '"')
target++;
FREE(ws->name); FREE(ws->name);
ws->name = strdup(bind->command + strlen("workspace ")); ws->name = strdup(target);
if (ws->name[strlen(ws->name)-1] == '"')
ws->name[strlen(ws->name)-1] = '\0';
DLOG("trying name *%s*\n", ws->name); DLOG("trying name *%s*\n", ws->name);
TAILQ_FOREACH(out, &(croot->nodes_head), nodes) TAILQ_FOREACH(out, &(croot->nodes_head), nodes)

View File

@ -30,15 +30,32 @@ exit_gracefully($process->pid);
# 2: with named workspaces, i3 should start on the first named one # 2: with named workspaces, i3 should start on the first named one
############################################################## ##############################################################
$config = <<EOT;
my $config = <<EOT;
# i3 config file (v4) # i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
bindsym Mod1+1 workspace foobar bindsym Mod1+1 workspace foobar
EOT EOT
my $process = launch_with_config($config); $process = launch_with_config($config);
my @names = @{get_workspace_names()};
cmp_deeply(\@names, [ 'foobar' ], 'i3 starts on named workspace foobar');
exit_gracefully($process->pid);
##############################################################
# 3: the same test as 2, but with a quoted workspace name
##############################################################
$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
bindsym Mod1+1 workspace "foobar"
EOT
$process = launch_with_config($config);
my @names = @{get_workspace_names()}; my @names = @{get_workspace_names()};
cmp_deeply(\@names, [ 'foobar' ], 'i3 starts on named workspace foobar'); cmp_deeply(\@names, [ 'foobar' ], 'i3 starts on named workspace foobar');