Skip to content

Commit

Permalink
readline: Make completion strings always unique
Browse files Browse the repository at this point in the history
There is no need to clutter the user's choices with repeating the same value
multiple times.

Signed-off-by: Hani Benhabiles <hani@linux.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
  • Loading branch information
kroosec authored and Luiz Capitulino committed Jun 11, 2014
1 parent e3bb532 commit e70871d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions util/readline.c
Expand Up @@ -263,6 +263,12 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
void readline_add_completion(ReadLineState *rs, const char *str)
{
if (rs->nb_completions < READLINE_MAX_COMPLETIONS) {
int i;
for (i = 0; i < rs->nb_completions; i++) {
if (!strcmp(rs->completions[i], str)) {
return;
}
}
rs->completions[rs->nb_completions++] = g_strdup(str);
}
}
Expand Down

0 comments on commit e70871d

Please sign in to comment.