diff options
author | LemonBoy <thatlemon@gmail.com> | 2016-06-12 22:58:35 +0200 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2016-06-12 22:58:35 +0200 |
commit | 7307b48bd6928207ded9e186af3f3b97625f00bb (patch) | |
tree | 987ca3e712cd7cd070441e24da3692c77e936378 /src/fe-common/core/completion.c | |
parent | 31f12c10df52e44e7cef0245fc55ae38159ce9e3 (diff) | |
download | irssi-7307b48bd6928207ded9e186af3f3b97625f00bb.zip |
Sort the completion results
Make sure the current option is shown first.
Diffstat (limited to 'src/fe-common/core/completion.c')
-rw-r--r-- | src/fe-common/core/completion.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index 0e9982d5..c87fdb50 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -690,19 +690,20 @@ static void sig_complete_set(GList **list, WINDOW_REC *window, else if (*line != '\0' && *word == '\0') { SETTINGS_REC *rec = settings_get_record(line); if (rec != NULL) { + char *value = settings_get_print(rec); + + /* show the current option first */ + if (value != NULL) + *list = g_list_append(*list, value); + /* show the whole list of valid options */ if (rec->type == SETTING_TYPE_CHOICE) { - char **tmp = rec->choices; - - while (*tmp) - *list = g_list_append(*list, g_strdup(*tmp++)); - } - /* show the current option */ - else { - char *value = settings_get_print(rec); + char **tmp; - if (value != NULL) - *list = g_list_append(*list, value); + for (tmp = rec->choices; *tmp; tmp++) { + if (g_ascii_strcasecmp(*tmp, value) != 0) + *list = g_list_append(*list, g_strdup(*tmp)); + } } } } |