aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/rename.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/rename.c')
-rw-r--r--sway/commands/rename.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sway/commands/rename.c b/sway/commands/rename.c
index c6952bbb..21d2aa64 100644
--- a/sway/commands/rename.c
+++ b/sway/commands/rename.c
@@ -1,4 +1,5 @@
#define _XOPEN_SOURCE 500
+#include <ctype.h>
#include <string.h>
#include <strings.h>
#include "log.h"
@@ -6,6 +7,7 @@
#include "sway/commands.h"
#include "sway/config.h"
#include "sway/ipc-server.h"
+#include "sway/output.h"
#include "sway/tree/container.h"
#include "sway/tree/workspace.h"
@@ -33,6 +35,10 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
}
} else if (strcasecmp(argv[1], "number") == 0) {
// 'rename workspace number x to new_name'
+ if (!isdigit(argv[2][0])) {
+ return cmd_results_new(CMD_INVALID, "rename",
+ "Invalid workspace number '%s'", argv[2]);
+ }
workspace = workspace_by_number(argv[2]);
while (argn < argc && strcasecmp(argv[argn], "to") != 0) {
++argn;
@@ -66,7 +72,8 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
strcasecmp(new_name, "next_on_output") == 0 ||
strcasecmp(new_name, "prev_on_output") == 0 ||
strcasecmp(new_name, "back_and_forth") == 0 ||
- strcasecmp(new_name, "current") == 0) {
+ strcasecmp(new_name, "current") == 0 ||
+ strcasecmp(new_name, "number") == 0) {
free(new_name);
return cmd_results_new(CMD_INVALID, "rename",
"Cannot use special workspace name '%s'", argv[argn]);
@@ -82,7 +89,7 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
free(workspace->name);
workspace->name = new_name;
- container_sort_workspaces(workspace->parent);
+ output_sort_workspaces(workspace->parent);
ipc_event_workspace(NULL, workspace, "rename");
return cmd_results_new(CMD_SUCCESS, NULL, NULL);