i3 - improved tiling WM


Fix command parser: resizing tiling windows

Patch status: merged

Patch by jj

Long description:

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.

To apply this patch, use:
curl http://cr.i3wm.org/patch/261/raw.patch | git am

b/parser-specs/commands.spec

17
@@ -209,11 +209,11 @@ state RESIZE_TILING:
18
       -> call cmd_resize($way, $direction, $resize_px, "10")
19
 
20
 state RESIZE_TILING_OR:
21
-  'ppt'
22
-      ->
23
   resize_ppt = word
24
-      ->
25
-  end
26
+      -> RESIZE_TILING_FINAL
27
+
28
+state RESIZE_TILING_FINAL:
29
+  'ppt', end
30
       -> call cmd_resize($way, $direction, $resize_px, $resize_ppt)
31
 
32
 # rename workspace <name> to <name>

b/testcases/t/187-commands-parser.t

37
@@ -171,4 +171,19 @@ is(parser_calls('workspace "foo \"bar"'),
38
    'cmd_workspace_name(foo "bar)',
39
    'Command with escaped double quotes ok');
40
 
41
+################################################################################
42
+# 4: Verify that resize commands with a "px or ppt"-construction are parsed
43
+# correctly
44
+################################################################################
45
+
46
+is(parser_calls("resize shrink width 10 px or"),
47
+   "ERROR: Expected one of these tokens: <word>\n" .
48
+   "ERROR: Your command: resize shrink width 10 px or\n" .
49
+   "ERROR:                                           ",
50
+   "error for resize command with incomplete 'or'-construction ok");
51
+
52
+is(parser_calls("resize grow left 10 px or 20 ppt"),
53
+   "cmd_resize(grow, left, 10, 20)",
54
+   "resize command with 'or'-construction ok");
55
+
56
 done_testing;