diff options
author | leo-arch <leonardoabramovich2@gmail.com> | 2024-04-27 18:34:47 -0300 |
---|---|---|
committer | leo-arch <leonardoabramovich2@gmail.com> | 2024-04-27 18:34:47 -0300 |
commit | b59c1326df93b849e62e98d1060412e2287c0150 (patch) | |
tree | 63fe899f170f2137b85489d0fb2d67c413105ad6 | |
parent | b618cfe9522a3a1b51de8a29488fd9d7e14df69b (diff) |
Workaround for 'ds' TAB completion
If the common prefix needs to be quoted, TAB completion for 'ds' does not work as expected
-rw-r--r-- | src/tabcomp.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/tabcomp.c b/src/tabcomp.c index 9d2cd2e5..5fe34104 100644 --- a/src/tabcomp.c +++ b/src/tabcomp.c @@ -1519,6 +1519,8 @@ get_finder_offset(const char *query, const char *text, char **matches, else if (ct == TCMP_DESEL && query) { finder_offset = prompt_offset + (int)(query - lb) - 3; + if (!*query && finder_offset > 0) + finder_offset--; } else if (ct == TCMP_HIST) { @@ -2153,6 +2155,14 @@ AFTER_USUAL_COMPLETION: should_quote = matches[0] && rl_completer_quote_characters && rl_filename_completion_desired && rl_filename_quoting_desired; +////////// + /* WORKAROUND: If 'ds' and the replacement string needs to be + * quoted, the completion do not work as expected. */ + if (cur_comp_type == TCMP_DESEL && matches[0] + && rl_strpbrk(matches[0], quote_chars)) + replacement = NULL; +////////// + if (should_quote) should_quote = (should_quote && !quote_char); @@ -2275,7 +2285,7 @@ AFTER_USUAL_COMPLETION: fputs(cur_color, stdout); } else { char *q = (*replacement == '\\' && *(replacement + 1) == '~') - ? replacement + 1 : replacement; + ? replacement + 1 : replacement; rl_insert_text(q); rl_redisplay(); } |