1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Merge pull request #1784 from MarcoPolo-PasTonMolo/fix/1783-url-save-ac-filenames

Make `/url save` autocomplete filenames after a url
This commit is contained in:
Michael Vetter 2023-01-02 15:09:20 +01:00 committed by GitHub
commit c5c33bdce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4352,7 +4352,21 @@ _url_autocomplete(ProfWin* window, const char* const input, gboolean previous)
return result; return result;
} }
result = autocomplete_param_with_func(input, "/url save", wins_get_url, previous, window); gboolean arg_result;
gchar** args = parse_args(input, 1, 8, &arg_result);
gboolean space_at_end = g_str_has_suffix(input, " ");
int num_args = g_strv_length(args);
if (arg_result) {
if ((num_args == 1 && space_at_end) || (num_args == 2 && !space_at_end)) {
result = autocomplete_param_with_func(input, "/url save", wins_get_url, previous, window);
} else if ((num_args == 2 && space_at_end) || (num_args == 3 && !space_at_end)) {
gchar* cmd = g_strdup_printf("/url save %s", args[1]);
result = cmd_ac_complete_filepath(input, cmd, previous);
g_free(cmd);
}
}
g_strfreev(args);
} }
return result; return result;