1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Finished chat room nick autocomplete

This commit is contained in:
James Booth 2014-07-15 21:30:23 +01:00
parent 2f3234a5f5
commit cc62fe376c
2 changed files with 22 additions and 10 deletions

View File

@ -579,16 +579,28 @@ muc_autocomplete(char *input, int *size)
char *result = NULL;
if (last_space == NULL) {
result = autocomplete_complete(nick_ac, input, FALSE);
if (result != NULL) {
ui_replace_input(input, result, size);
g_free(result);
return;
}
} else {
int len = (last_space - input);
char *start_str = strndup(input, len);
result = autocomplete_param_with_ac(input, size, start_str, nick_ac, FALSE);
free(start_str);
}
if (result != NULL) {
ui_replace_input(input, result, size);
g_free(result);
return;
char *search_str = last_space+1;
if (*search_str != '\0') {
result = autocomplete_complete(nick_ac, search_str, FALSE);
if (result != NULL) {
if (g_str_has_suffix(input, result) == FALSE) {
gchar *start_str = g_strndup(input, search_str - input);
GString *replace_with = g_string_new(start_str);
g_string_append(replace_with, result);
ui_replace_input(input, replace_with->str, size);
g_string_free(replace_with, TRUE);
g_free(start_str);
g_free(result);
return;
}
}
}
}
}
}

View File

@ -171,7 +171,7 @@ autocomplete_complete(Autocomplete ac, gchar *search_str, gboolean quote)
// subsequent search attempt
} else {
// search from here+1 tp end
// search from here+1 to end
found = _search_from(ac, g_slist_next(ac->last_found), quote);
if (found != NULL)
return found;