]> git.sur5r.net Git - i3/i3/commitdiff
Fix command parser: resizing tiling windows
authorjj <haptix@web.de>
Wed, 9 Oct 2013 20:30:41 +0000 (22:30 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 13 Oct 2013 16:02:40 +0000 (18:02 +0200)
i3 would accept an invalid resize command like 'resize shrink width 10
px or' without specifying the ppt value, and then crash. This patch
fixes the parser specification.

parser-specs/commands.spec
testcases/t/187-commands-parser.t

index 2c640c65ae9e5f6a69daaba084641a2003de6722..e3da62c91aae2b2ca39c6d19f6163a06b91b3f6b 100644 (file)
@@ -209,11 +209,11 @@ state RESIZE_TILING:
       -> call cmd_resize($way, $direction, $resize_px, "10")
 
 state RESIZE_TILING_OR:
-  'ppt'
-      ->
   resize_ppt = word
-      ->
-  end
+      -> RESIZE_TILING_FINAL
+
+state RESIZE_TILING_FINAL:
+  'ppt', end
       -> call cmd_resize($way, $direction, $resize_px, $resize_ppt)
 
 # rename workspace <name> to <name>
index bbb89d93be9d902aaf56089e2d3f78bddb0f9a6e..5ee94f876f141b5c8133b47c506582ef9259a10a 100644 (file)
@@ -171,4 +171,19 @@ is(parser_calls('workspace "foo \"bar"'),
    'cmd_workspace_name(foo "bar)',
    'Command with escaped double quotes ok');
 
+################################################################################
+# 4: Verify that resize commands with a "px or ppt"-construction are parsed
+# correctly
+################################################################################
+
+is(parser_calls("resize shrink width 10 px or"),
+   "ERROR: Expected one of these tokens: <word>\n" .
+   "ERROR: Your command: resize shrink width 10 px or\n" .
+   "ERROR:                                           ",
+   "error for resize command with incomplete 'or'-construction ok");
+
+is(parser_calls("resize grow left 10 px or 20 ppt"),
+   "cmd_resize(grow, left, 10, 20)",
+   "resize command with 'or'-construction ok");
+
 done_testing;