Skip to content

Commit

Permalink
Workaround for 'ds' TAB completion
Browse files Browse the repository at this point in the history
If the common prefix needs to be quoted, TAB completion for 'ds' does not work as expected
  • Loading branch information
leo-arch committed Apr 27, 2024
1 parent b618cfe commit b59c132
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/tabcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -2153,6 +2155,14 @@ tab_complete(const int what_to_do)
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);

Expand Down Expand Up @@ -2275,7 +2285,7 @@ tab_complete(const int what_to_do)
fputs(cur_color, stdout);
} else {
char *q = (*replacement == '\\' && *(replacement + 1) == '~')
? replacement + 1 : replacement;
? replacement + 1 : replacement;
rl_insert_text(q);
rl_redisplay();
}
Expand Down

0 comments on commit b59c132

Please sign in to comment.