More tidy of bookmark autocomplete

This commit is contained in:
James Booth
2014-05-14 21:01:54 +01:00
parent bd55e7a978
commit 75898a777a

View File

@@ -1665,13 +1665,14 @@ _bookmark_autocomplete(char *input, int *size)
gboolean result; gboolean result;
gchar **args = parse_args(input, 3, 8, &result); gchar **args = parse_args(input, 3, 8, &result);
gboolean handle_options = result && (g_strv_length(args) > 2);
if (result && ((strcmp(args[0], "add") == 0) || (strcmp(args[0], "update") == 0)) ) { if (handle_options && ((strcmp(args[0], "add") == 0) || (strcmp(args[0], "update") == 0)) ) {
GString *beginning = g_string_new("/bookmark "); GString *beginning = g_string_new("/bookmark");
gboolean autojoin = FALSE; gboolean autojoin = FALSE;
int num_args = g_strv_length(args); int num_args = g_strv_length(args);
if (num_args > 2) { g_string_append(beginning, " ");
g_string_append(beginning, args[0]); g_string_append(beginning, args[0]);
g_string_append(beginning, " "); g_string_append(beginning, " ");
g_string_append(beginning, args[1]); g_string_append(beginning, args[1]);
@@ -1680,7 +1681,6 @@ _bookmark_autocomplete(char *input, int *size)
g_string_append(beginning, args[2]); g_string_append(beginning, args[2]);
autojoin = TRUE; autojoin = TRUE;
} }
}
if (num_args > 4) { if (num_args > 4) {
g_string_append(beginning, " "); g_string_append(beginning, " ");
@@ -1706,7 +1706,6 @@ _bookmark_autocomplete(char *input, int *size)
} }
} }
if (num_args > 2) {
if (autojoin) { if (autojoin) {
found = autocomplete_param_with_func(input, size, beginning->str, prefs_autocomplete_boolean_choice); found = autocomplete_param_with_func(input, size, beginning->str, prefs_autocomplete_boolean_choice);
} else { } else {
@@ -1717,7 +1716,6 @@ _bookmark_autocomplete(char *input, int *size)
return found; return found;
} }
} }
}
found = autocomplete_param_with_func(input, size, "/bookmark remove", bookmark_find); found = autocomplete_param_with_func(input, size, "/bookmark remove", bookmark_find);
if (found != NULL) { if (found != NULL) {