diff --git a/i3-migrate-config-to-v4.pl b/i3-migrate-config-to-v4.pl index 3a27c943..7e4f61ce 100755 --- a/i3-migrate-config-to-v4.pl +++ b/i3-migrate-config-to-v4.pl @@ -83,6 +83,21 @@ if (!need_to_convert()) { 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) { # directly use comments and empty lines if ($line =~ /^#/ || $line =~ /^$/) { @@ -141,8 +156,7 @@ for my $line (@lines) { print "$line\n"; next; } else { - print "# XXX: workspace name will end up in the bindings, see below\n"; - $workspace_names{$number} = $params; + print "# XXX: workspace name will end up in the corresponding bindings.\n"; next; } } diff --git a/testcases/t/71-config-migrate.t b/testcases/t/71-config-migrate.t index 11c70bfa..ec46eb33 100644 --- a/testcases/t/71-config-migrate.t +++ b/testcases/t/71-config-migrate.t @@ -297,6 +297,15 @@ $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'); +# The same, but in reverse order +$input = <