migrate-config: also handle named workspaces correctly when their names come after the bindings (Thanks xpt)
This commit is contained in:
parent
95ee21dc3b
commit
03aa95813e
@ -83,6 +83,21 @@ if (!need_to_convert()) {
|
|||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# first pass: get workspace names
|
||||||
|
for my $line (@lines) {
|
||||||
|
next if $line =~ /^#/ || $line =~ /^$/;
|
||||||
|
|
||||||
|
my ($statement, $parameters) = ($line =~ /([a-zA-Z._-]+)(.*)/);
|
||||||
|
|
||||||
|
# skip everything but workspace lines
|
||||||
|
next unless defined($statement) and $statement eq 'workspace';
|
||||||
|
|
||||||
|
my ($number, $params) = ($parameters =~ /[ \t]+([0-9]+) (.+)/);
|
||||||
|
|
||||||
|
# save workspace name (unless the line is actually a workspace assignment)
|
||||||
|
$workspace_names{$number} = $params unless $params =~ /^output/;
|
||||||
|
}
|
||||||
|
|
||||||
for my $line (@lines) {
|
for my $line (@lines) {
|
||||||
# directly use comments and empty lines
|
# directly use comments and empty lines
|
||||||
if ($line =~ /^#/ || $line =~ /^$/) {
|
if ($line =~ /^#/ || $line =~ /^$/) {
|
||||||
@ -141,8 +156,7 @@ for my $line (@lines) {
|
|||||||
print "$line\n";
|
print "$line\n";
|
||||||
next;
|
next;
|
||||||
} else {
|
} else {
|
||||||
print "# XXX: workspace name will end up in the bindings, see below\n";
|
print "# XXX: workspace name will end up in the corresponding bindings.\n";
|
||||||
$workspace_names{$number} = $params;
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,6 +297,15 @@ $output = migrate_config($input);
|
|||||||
ok(!line_exists($output, qr|^workspace|), 'workspace name not present');
|
ok(!line_exists($output, qr|^workspace|), 'workspace name not present');
|
||||||
ok(line_exists($output, qr|^bindsym Mod1\+3 workspace work|), 'named workspace in bindings');
|
ok(line_exists($output, qr|^bindsym Mod1\+3 workspace work|), 'named workspace in bindings');
|
||||||
|
|
||||||
|
# The same, but in reverse order
|
||||||
|
$input = <<EOT;
|
||||||
|
bindsym Mod1+3 3
|
||||||
|
workspace 3 work
|
||||||
|
EOT
|
||||||
|
$output = migrate_config($input);
|
||||||
|
ok(!line_exists($output, qr|^workspace|), 'workspace name not present');
|
||||||
|
ok(line_exists($output, qr|^bindsym Mod1\+3 workspace work|), 'named workspace in bindings');
|
||||||
|
|
||||||
$output = migrate_config('bindsym Mod1+3 3');
|
$output = migrate_config('bindsym Mod1+3 3');
|
||||||
ok(line_exists($output, qr|^bindsym Mod1\+3 workspace 3|), 'workspace changed');
|
ok(line_exists($output, qr|^bindsym Mod1\+3 workspace 3|), 'workspace changed');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user