From: hwangcc23 Date: Sun, 11 Jun 2017 15:48:55 +0000 (+0800) Subject: Fix 'rename workspace to tosomething' X-Git-Tag: 4.14~22^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=refs%2Fpull%2F2808%2Fhead;p=i3%2Fi3 Fix 'rename workspace to tosomething' This patch fixes the issue #2802 (https://github.com/i3/i3/issues/2802). 1). Revise the state machine for the 'rename workspace' command. These scenarios are considered: a). 'rename workspace to to bla' state transitions: RENAME -> RENAME_WORKSPACE -> RENAME_WORKSPACE_LIKELY_TO -> RENAME_WORKSPACE_LIKELY_TO_NEW_NAME b). 'rename workspace to tosomething' state transitions: RENAME -> RENAME_WORKSPACE -> RENAME_WORKSPACE_LIKELY_TO c). 'rename workspace to to' state transitions: RENAME -> RENAME_WORKSPACE -> RENAME_WORKSPACE_LIKELY_TO d). 'rename workspace to bla' state transitions: RENAME -> RENAME_WORKSPACE -> RENAME_WORKSPACE_LIKELY_TO e). 'rename workspace bla to foo' state transitions: RENAME -> RENAME_WORKSPACE -> RENAME_WORKSPACE_TO -> RENAME_WORKSPACE_TO_NEW_NAME 2). Add a test case in 117-workspace.t for the scenario b. --- diff --git a/parser-specs/commands.spec b/parser-specs/commands.spec index 0858322b..a5873328 100644 --- a/parser-specs/commands.spec +++ b/parser-specs/commands.spec @@ -274,24 +274,28 @@ state RENAME: -> RENAME_WORKSPACE state RENAME_WORKSPACE: - old_name = 'to' + 'to' -> RENAME_WORKSPACE_LIKELY_TO old_name = word -> RENAME_WORKSPACE_TO state RENAME_WORKSPACE_LIKELY_TO: - 'to' - -> RENAME_WORKSPACE_NEW_NAME + 'to ' + -> RENAME_WORKSPACE_LIKELY_TO_NEW_NAME new_name = word -> call cmd_rename_workspace(NULL, $new_name) +state RENAME_WORKSPACE_LIKELY_TO_NEW_NAME: + new_name = string + -> call cmd_rename_workspace("to", $new_name) + end + -> call cmd_rename_workspace(NULL, "to") + state RENAME_WORKSPACE_TO: 'to' - -> RENAME_WORKSPACE_NEW_NAME + -> RENAME_WORKSPACE_TO_NEW_NAME -state RENAME_WORKSPACE_NEW_NAME: - end - -> call cmd_rename_workspace(NULL, "to") +state RENAME_WORKSPACE_TO_NEW_NAME: new_name = string -> call cmd_rename_workspace($old_name, $new_name) diff --git a/testcases/t/117-workspace.t b/testcases/t/117-workspace.t index 01d51cc0..40b2cbb6 100644 --- a/testcases/t/117-workspace.t +++ b/testcases/t/117-workspace.t @@ -279,6 +279,12 @@ is(focused_ws(), 'bla', 'now on workspace bla'); cmd 'rename workspace to to'; ok(!workspace_exists('bla'), 'workspace bla does not exist anymore'); is(focused_ws(), 'to', 'now on workspace to'); +cmd 'rename workspace to bla'; +ok(!workspace_exists('to'), 'workspace to does not exist anymore'); +is(focused_ws(), 'bla', 'now on workspace bla'); +cmd 'rename workspace to tosomething'; +ok(!workspace_exists('bla'), 'workspace bla does not exist anymore'); +is(focused_ws(), 'tosomething', 'now on workspace tosomething'); # 6: already existing workspace my $result = cmd 'rename workspace qux to 11: bar';