commit 58ca97ce41cc0ec081488e437a8b32161827d548
parent 6f0dbca27bac03e6c9b5232ad95f0e17150f7900
Author: hhvn <dev@hhvn.uk>
Date: Sat, 12 Mar 2022 21:30:10 +0000
Don't submit empty input
Diffstat:
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/ui.c b/src/ui.c
@@ -465,14 +465,16 @@ ui_read(void) {
break;
case KEY_ENTER:
case '\r':
- command_eval(selected.server, input.string);
- /* free checks for null */
- free(input.history[INPUT_HIST_MAX - 1]);
- memmove(input.history + 1, input.history, (sizeof(input.history) / INPUT_HIST_MAX) * (INPUT_HIST_MAX - 1));
- input.history[0] = estrdup(input.string);
- input.string[0] = '\0';
- input.counter = 0;
- input.histindex = -1;
+ if (*input.string != '\0') {
+ command_eval(selected.server, input.string);
+ /* free checks for null */
+ free(input.history[INPUT_HIST_MAX - 1]);
+ memmove(input.history + 1, input.history, (sizeof(input.history) / INPUT_HIST_MAX) * (INPUT_HIST_MAX - 1));
+ input.history[0] = estrdup(input.string);
+ input.string[0] = '\0';
+ input.counter = 0;
+ input.histindex = -1;
+ }
break;
default:
if ((key & 0xFF80) == 0x80 || isprint(key) || iscntrl(key)) {