From 6597d3e5a5826af8a6b7af2fb1a749ef65088518 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 13 Dec 2021 02:29:32 +0100 Subject: [PATCH] readline autocomplete: complete up to next space, so complete one single word at once --- client/pyscripts/pm3_help2list.py | 7 ++++++- client/src/rl_vocabulory.h | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/client/pyscripts/pm3_help2list.py b/client/pyscripts/pm3_help2list.py index abda16a5a..637e10e6d 100755 --- a/client/pyscripts/pm3_help2list.py +++ b/client/pyscripts/pm3_help2list.py @@ -121,7 +121,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); } } diff --git a/client/src/rl_vocabulory.h b/client/src/rl_vocabulory.h index 535b00a2b..ae74f3f8f 100644 --- a/client/src/rl_vocabulory.h +++ b/client/src/rl_vocabulory.h @@ -731,7 +731,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); } }