From 067c2e793e41765300006648b1fa546b42913805 Mon Sep 17 00:00:00 2001 From: ERAMOTO Masaya Date: Tue, 5 Sep 2017 13:50:42 +0900 Subject: [PATCH] client: Fix completion for list/pair command The unexpected generator is used if the input string forward matches with the unexpected command string which a generator for completion is registered on. Thus, - since 496b6abf743440e937222c62768e0a3b31f47f02, list command generates the unneeded argument, which is device id like that list-attributes command generates. - since b0fe6045b7d9cfdd02a5e419fc9658a0ffa84619, pair command generates the invalid argument, which is on/off like that pairable command generates. This patch use the exact matching command. --- client/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/main.c b/client/main.c index 2cb449fd5..0095aa014 100644 --- a/client/main.c +++ b/client/main.c @@ -2601,10 +2601,11 @@ static char **cmd_completion(const char *text, int start, int end) if (start > 0) { int i; + char *input_cmd; + input_cmd = g_strndup(rl_line_buffer, start -1); for (i = 0; cmd_table[i].cmd; i++) { - if (strncmp(cmd_table[i].cmd, - rl_line_buffer, start - 1)) + if (strcmp(cmd_table[i].cmd, input_cmd)) continue; if (!cmd_table[i].gen) @@ -2614,6 +2615,7 @@ static char **cmd_completion(const char *text, int start, int end) matches = rl_completion_matches(text, cmd_table[i].gen); break; } + g_free(input_cmd); } else { rl_completion_display_matches_hook = NULL; matches = rl_completion_matches(text, cmd_generator); -- 2.47.3