From f26b1b7d1311c34b1ed4ec29b5d26e3ae421873b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Fri, 26 Feb 2016 18:32:27 +0100 Subject: Always insert single match of explicit complete function If an explicit complete function has only one match but is used directly after the default tab completion, than the single match is shown instead of inserted. The solution is resetting the 'rl_last_func' variable if it is set to 'rl_complete' when using an explicit complete function. --- edit-readline.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'edit-readline.c') diff --git a/edit-readline.c b/edit-readline.c index fb9044e..58b686e 100644 --- a/edit-readline.c +++ b/edit-readline.c @@ -111,19 +111,23 @@ static char **rc_completion(const char *text, int start, int end) { return NULL; } -static int rc_complete_command(int count, int key) { - compentry_func = compl_extcmd; +static int expl_complete(rl_compentry_func_t *func, int count, int key) { + if (rl_last_func == rl_complete) + rl_last_func = NULL; + compentry_func = func; return rl_complete(count, key); } +static int rc_complete_command(int count, int key) { + return expl_complete(compl_extcmd, count, key); +} + static int rc_complete_filename(int count, int key) { - compentry_func = rl_filename_completion_function; - return rl_complete(count, key); + return expl_complete(rl_filename_completion_function, count, key); } static int rc_complete_variable(int count, int key) { - compentry_func = compl_var; - return rl_complete(count, key); + return expl_complete(compl_var, count, key); } void *edit_begin(int fd) { -- cgit v1.2.3