diff options
author | MarcoPolo-PasTonMolo <marcopolopastonmolo@protonmail.com> | 2022-12-24 21:03:24 +0200 |
---|---|---|
committer | MarcoPolo-PasTonMolo <marcopolopastonmolo@protonmail.com> | 2022-12-27 14:39:31 +0200 |
commit | 525ec11e4619409a95f8506dd2bf9a2724f69d37 (patch) | |
tree | 61b0cf5fd8f3ac74ab22c0bc06aa4cbd1e0e75ab /src/command | |
parent | 49ab1f3230302510a35a7ba17ec44248a090ce56 (diff) | |
download | profani-tty-525ec11e4619409a95f8506dd2bf9a2724f69d37.tar.gz |
Make `/url save` autocomplete filenames after a url
Previously after the url if you pressed tab, even if you typed out a filepath, profanity would erase that and cycle through url autocomplete results. This patch solves that and autocompletes filepaths after the url. Fixes https://github.com/profanity-im/profanity/issues/1783
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_ac.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 9a839258..4fc2e63d 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -4352,7 +4352,21 @@ _url_autocomplete(ProfWin* window, const char* const input, gboolean previous) 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; |