summaryrefslogtreecommitdiff
path: root/edit-readline.c
diff options
context:
space:
mode:
authorBert Münnich <b.muennich@stagetec.com>2016-02-26 18:32:27 +0100
committerToby Goodwin <toby@paccrat.org>2018-04-26 07:45:38 +0100
commitf26b1b7d1311c34b1ed4ec29b5d26e3ae421873b (patch)
tree0824c79efda48f1f12460eccaac7bf676a11bb9d /edit-readline.c
parenta50b93cd6790c95a85c7647829c14a0ccd166f31 (diff)
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.
Diffstat (limited to 'edit-readline.c')
-rw-r--r--edit-readline.c16
1 files changed, 10 insertions, 6 deletions
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) {