summary refs log tree commit diff
path: root/input.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--input.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/input.c b/input.c
index 9bf29ac..4d34420 100644
--- a/input.c
+++ b/input.c
@@ -172,21 +172,31 @@ void input(struct Tag tag, char *input) {
 		return;
 	}
 
-	char *command = strsep(&input, " ");
+	char *word = strsep(&input, " ");
 	if (input && !input[0]) input = NULL;
-	for (size_t i = 0; i < COMMANDS_LEN; ++i) {
-		if (strcasecmp(command, COMMANDS[i].command)) continue;
-		COMMANDS[i].handler(tag, input);
-		return;
-	}
 
 	char *trail;
-	strtol(&command[1], &trail, 0);
+	strtol(&word[1], &trail, 0);
 	if (!trail[0]) {
-		inputView(tag, &command[1]);
+		inputView(tag, &word[1]);
+		return;
+	}
+
+	const char *command = word;
+	const char *uniq = tabNext(TAG_NONE, command);
+	if (uniq && uniq == tabNext(TAG_NONE, command)) {
+		command = uniq;
+		tabAccept();
 	} else {
-		uiFmt(TAG_STATUS, UI_WARM, "%s isn't a recognized command", command);
+		tabReject();
+	}
+
+	for (size_t i = 0; i < COMMANDS_LEN; ++i) {
+		if (strcasecmp(command, COMMANDS[i].command)) continue;
+		COMMANDS[i].handler(tag, input);
+		return;
 	}
+	uiFmt(TAG_STATUS, UI_WARM, "%s isn't a recognized command", command);
 }
 
 void inputTab(void) {