summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-06-17 13:04:19 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-06-17 13:04:19 +0000
commit8c60237fbec24decaaa718a15467eaeab859d55c (patch)
tree3cff6964bcbb228f9060ccba5d167462fc25c601 /src
parentea00d4c94847a3670630417402a4c6c1d41d9f82 (diff)
downloadirssi-8c60237fbec24decaaa718a15467eaeab859d55c.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/fe-common/core/completion.c12
1 files 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);