From f2650e7279217f7a88394a07bf10464d898d5e7a Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 13 Dec 2021 00:25:07 +0100 Subject: [PATCH] readline autocomplete: complete up to next space, so complete one single word at once --- client/src/rl_vocabulory.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/rl_vocabulory.h b/client/src/rl_vocabulory.h index e72a396b7..b1b927977 100644 --- a/client/src/rl_vocabulory.h +++ b/client/src/rl_vocabulory.h @@ -732,7 +732,12 @@ char* rl_command_generator(const char *text, int state) { index++; if (strncmp (command, rl_line_buffer, rlen) == 0) { - return strdup(command + (rlen - len)); + const char *next = command + (rlen - len); + const char *space = strstr(next, " "); + if (space != NULL) { + return strndup(next, space - next); + } + return strdup(next); } }