From 8c60237fbec24decaaa718a15467eaeab859d55c Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 17 Jun 2000 13:04:19 +0000 Subject: [PATCH] Don't add same /command more than once to completion list. Completion didn't work right when completing subcommands's subcommand. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@359 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/core/completion.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index f154f0d2..fa9d628b 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -204,6 +204,7 @@ static GList *completion_get_commands(const char *cmd, char cmdchar) { GList *complist; GSList *tmp; + char *word; int len; len = strlen(cmd); @@ -214,8 +215,13 @@ static GList *completion_get_commands(const char *cmd, char cmdchar) if (strchr(rec->cmd, ' ') != NULL) continue; - if (g_strncasecmp(rec->cmd, cmd, len) == 0) - complist = g_list_append(complist, g_strdup_printf("%c%s", cmdchar, rec->cmd)); + if (g_strncasecmp(rec->cmd, cmd, len) == 0) { + word = g_strdup_printf("%c%s", cmdchar, rec->cmd); + if (glist_find_icase_string(complist, word) == NULL) + complist = g_list_append(complist, word); + else + g_free(word); + } } return complist; } @@ -228,7 +234,7 @@ static GList *completion_get_subcommands(const char *cmd) int len, skip; /* get the number of chars to skip at the start of command. */ - spacepos = strchr(cmd, ' '); + spacepos = strrchr(cmd, ' '); skip = spacepos == NULL ? 0 : ((int) (spacepos-cmd) + 1);