diff --git a/src/cmdparse.y b/src/cmdparse.y index c38f660f..fba4a3cf 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -485,7 +485,7 @@ focus: int to_focus = $2; if ($2 == TOK_MODE_TOGGLE) { current = TAILQ_FIRST(&(ws->focus_head)); - if (current->type == CT_FLOATING_CON) + if (current != NULL && current->type == CT_FLOATING_CON) to_focus = TOK_TILING; else to_focus = TOK_FLOATING; } diff --git a/testcases/t/74-regress-focus-toggle.t b/testcases/t/74-regress-focus-toggle.t new file mode 100644 index 00000000..469d1be8 --- /dev/null +++ b/testcases/t/74-regress-focus-toggle.t @@ -0,0 +1,17 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# +# Regression: Checks if i3 still lives after using 'focus mode_toggle' on an +# empty workspace. This regression was fixed in +# 0848844f2d41055f6ffc69af1149d7a873460976. +# +use i3test; +use v5.10; + +my $tmp = fresh_workspace; + +cmd 'focus mode_toggle'; + +does_i3_live; + +done_testing;