From baffcc7b76e6f35ea0b35586540969e7faae5572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 28 Jun 2014 11:48:49 +0200 Subject: core: fix completion of plugins commands when beginning of command is given --- src/core/wee-completion.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/wee-completion.c b/src/core/wee-completion.c index 76f67da11..7301ffde9 100644 --- a/src/core/wee-completion.c +++ b/src/core/wee-completion.c @@ -833,7 +833,7 @@ completion_list_add_plugins_commands_cb (void *data, struct t_gui_completion *completion) { char **argv; - int argc; + int argc, arg_index; struct t_weechat_plugin *ptr_plugin; struct t_hook *ptr_hook; @@ -850,14 +850,17 @@ completion_list_add_plugins_commands_cb (void *data, if (argc > 0) { + arg_index = completion->base_command_arg_index - 2; + if ((arg_index < 0) || (arg_index > argc - 1)) + arg_index = argc - 1; ptr_plugin = NULL; - if (string_strcasecmp (argv[argc - 1], PLUGIN_CORE) != 0) + if (string_strcasecmp (argv[arg_index], PLUGIN_CORE) != 0) { /* * plugin name is different from "core", then search it in * plugin list */ - ptr_plugin = plugin_search (argv[argc - 1]); + ptr_plugin = plugin_search (argv[arg_index]); if (!ptr_plugin) return WEECHAT_RC_OK; } -- cgit v1.2.3