1
1

(try_complete): fix completion for file names started with one character.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2010-12-22 11:17:15 +03:00
родитель e4de4f00d1
Коммит 16c37545a3

@ -815,32 +815,37 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
int in_command_position = 0; int in_command_position = 0;
char *word; char *word;
char **matches = NULL; char **matches = NULL;
const char *command_separator_chars = ";|&{(`";
char *p = NULL, *q = NULL, *r = NULL; char *p = NULL, *q = NULL, *r = NULL;
gboolean is_cd = check_is_cd (text, *lc_start, flags); gboolean is_cd;
char *ti;
SHOW_C_CTX ("try_complete"); SHOW_C_CTX ("try_complete");
word = g_strndup (text + *lc_start, *lc_end - *lc_start); word = g_strndup (text + *lc_start, *lc_end - *lc_start);
is_cd = check_is_cd (text, *lc_start, flags);
/* Determine if this could be a command word. It is if it appears at /* Determine if this could be a command word. It is if it appears at
the start of the line (ignoring preceding whitespace), or if it the start of the line (ignoring preceding whitespace), or if it
appears after a character that separates commands. And we have to appears after a character that separates commands. And we have to
be in a INPUT_COMPLETE_COMMANDS flagged Input line. */ be in a INPUT_COMPLETE_COMMANDS flagged Input line. */
if (!is_cd && (flags & INPUT_COMPLETE_COMMANDS)) if (!is_cd && (flags & INPUT_COMPLETE_COMMANDS))
{ {
const char *command_separator_chars = ";|&{(`";
char *ti;
if (*lc_start == 0)
ti = text;
else
ti = str_get_prev_char (&text[*lc_start]); ti = str_get_prev_char (&text[*lc_start]);
while (ti > text && (ti[0] == ' ' || ti[0] == '\t')) while (ti > text && (ti[0] == ' ' || ti[0] == '\t'))
str_prev_char (&ti); str_prev_char (&ti);
if (ti <= text && (ti[0] == ' ' || ti[0] == '\t'))
in_command_position++; if (strchr (command_separator_chars, ti[0]) != NULL)
else if (strchr (command_separator_chars, ti[0]))
{ {
register int this_char, prev_char; int this_char, prev_char;
in_command_position++; in_command_position++;
if (ti > text) if (ti != text)
{ {
/* Handle the two character tokens `>&', `<&', and `>|'. /* Handle the two character tokens `>&', `<&', and `>|'.
We are not in a command position after one of these. */ We are not in a command position after one of these. */
@ -848,10 +853,8 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
prev_char = str_get_prev_char (ti)[0]; prev_char = str_get_prev_char (ti)[0];
if ((this_char == '&' && (prev_char == '<' || prev_char == '>')) || if ((this_char == '&' && (prev_char == '<' || prev_char == '>')) ||
(this_char == '|' && prev_char == '>')) (this_char == '|' && prev_char == '>') ||
in_command_position = 0; (ti != text && str_get_prev_char (ti)[0] == '\\')) /* Quoted */
else if (ti > text && str_get_prev_char (ti)[0] == '\\') /* Quoted */
in_command_position = 0; in_command_position = 0;
} }
} }