diff options
author | Ian Fan <ianfan0@gmail.com> | 2018-08-06 12:46:28 +0100 |
---|---|---|
committer | Ian Fan <ianfan0@gmail.com> | 2018-08-06 14:17:58 +0100 |
commit | f7c21451dfa7c4ffdce1307b5856707a0ed40405 (patch) | |
tree | 3df803a95c0a13f4dc9b627db505ba50d5e6a6d2 /sway/commands | |
parent | commands: check for special workspaces in workspace & move commands (diff) | |
download | sway-f7c21451dfa7c4ffdce1307b5856707a0ed40405.tar.gz sway-f7c21451dfa7c4ffdce1307b5856707a0ed40405.tar.zst sway-f7c21451dfa7c4ffdce1307b5856707a0ed40405.zip |
commands: fix workspace edge cases
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/move.c | 9 | ||||
-rw-r--r-- | sway/commands/rename.c | 10 |
2 files changed, 17 insertions, 2 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c index 500151f7..af3dc538 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -107,8 +107,13 @@ static struct cmd_results *cmd_move_container(struct sway_container *current, | |||
107 | strcasecmp(argv[2], "current") == 0) { | 107 | strcasecmp(argv[2], "current") == 0) { |
108 | ws = workspace_by_name(argv[2]); | 108 | ws = workspace_by_name(argv[2]); |
109 | } else if (strcasecmp(argv[2], "back_and_forth") == 0) { | 109 | } else if (strcasecmp(argv[2], "back_and_forth") == 0) { |
110 | if (!(ws = workspace_by_name(argv[0])) && prev_workspace_name) { | 110 | if (!(ws = workspace_by_name(argv[2]))) { |
111 | ws = workspace_create(NULL, prev_workspace_name); | 111 | if (prev_workspace_name) { |
112 | ws = workspace_create(NULL, prev_workspace_name); | ||
113 | } else { | ||
114 | return cmd_results_new(CMD_FAILURE, "move", | ||
115 | "No workspace was previously active."); | ||
116 | } | ||
112 | } | 117 | } |
113 | } else { | 118 | } else { |
114 | char *ws_name = NULL; | 119 | char *ws_name = NULL; |
diff --git a/sway/commands/rename.c b/sway/commands/rename.c index a380ff9c..c6952bbb 100644 --- a/sway/commands/rename.c +++ b/sway/commands/rename.c | |||
@@ -61,6 +61,16 @@ struct cmd_results *cmd_rename(int argc, char **argv) { | |||
61 | } | 61 | } |
62 | 62 | ||
63 | char *new_name = join_args(argv + argn, argc - argn); | 63 | char *new_name = join_args(argv + argn, argc - argn); |
64 | if (strcasecmp(new_name, "next") == 0 || | ||
65 | strcasecmp(new_name, "prev") == 0 || | ||
66 | strcasecmp(new_name, "next_on_output") == 0 || | ||
67 | strcasecmp(new_name, "prev_on_output") == 0 || | ||
68 | strcasecmp(new_name, "back_and_forth") == 0 || | ||
69 | strcasecmp(new_name, "current") == 0) { | ||
70 | free(new_name); | ||
71 | return cmd_results_new(CMD_INVALID, "rename", | ||
72 | "Cannot use special workspace name '%s'", argv[argn]); | ||
73 | } | ||
64 | struct sway_container *tmp_workspace = workspace_by_name(new_name); | 74 | struct sway_container *tmp_workspace = workspace_by_name(new_name); |
65 | if (tmp_workspace) { | 75 | if (tmp_workspace) { |
66 | free(new_name); | 76 | free(new_name); |