mirror of
https://github.com/weechat/weechat.git
synced 2026-06-25 04:16:38 +02:00
core: fix completion template used in command completion when first argument in template has pipes
This commit is contained in:
+2
-2
@@ -482,7 +482,7 @@ hook_command_build_completion (struct t_hook_command *hook_command)
|
||||
{
|
||||
/*
|
||||
* build static part of template: it's first argument(s) which does not
|
||||
* contain "%" or "|"
|
||||
* contain "%"
|
||||
*/
|
||||
last_space = NULL;
|
||||
ptr_template = hook_command->cplt_templates[i];
|
||||
@@ -493,7 +493,7 @@ hook_command_build_completion (struct t_hook_command *hook_command)
|
||||
last_space = ptr_template;
|
||||
break;
|
||||
}
|
||||
else if ((ptr_template[0] == '%') || (ptr_template[0] == '|'))
|
||||
else if (ptr_template[0] == '%')
|
||||
break;
|
||||
ptr_template = utf8_next_char (ptr_template);
|
||||
}
|
||||
|
||||
@@ -478,7 +478,8 @@ int
|
||||
gui_completion_get_matching_template (struct t_gui_completion *completion,
|
||||
struct t_hook *hook_command)
|
||||
{
|
||||
int i, length, fallback;
|
||||
int i, j, length, fallback, num_items;
|
||||
char **items;
|
||||
|
||||
/* without at least one argument, we can't find matching template! */
|
||||
if (completion->base_command_arg_index <= 1)
|
||||
@@ -488,13 +489,23 @@ gui_completion_get_matching_template (struct t_gui_completion *completion,
|
||||
|
||||
for (i = 0; i < HOOK_COMMAND(hook_command, cplt_num_templates); i++)
|
||||
{
|
||||
length = strlen (HOOK_COMMAND(hook_command, cplt_templates_static)[i]);
|
||||
if ((strncmp (HOOK_COMMAND(hook_command, cplt_templates_static)[i],
|
||||
completion->args, length) == 0)
|
||||
&& (completion->args[length] == ' '))
|
||||
items = string_split (HOOK_COMMAND(hook_command, cplt_templates_static)[i],
|
||||
"|", 0, 0, &num_items);
|
||||
if (items)
|
||||
{
|
||||
return i;
|
||||
for (j = 0; j < num_items; j++)
|
||||
{
|
||||
length = strlen (items[j]);
|
||||
if ((strncmp (items[j], completion->args, length) == 0)
|
||||
&& (completion->args[length] == ' '))
|
||||
{
|
||||
string_free_split (items);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
string_free_split (items);
|
||||
}
|
||||
|
||||
/*
|
||||
* try to find a fallback template if we don't find any matching
|
||||
* template, for example with these templates (command /set):
|
||||
|
||||
Reference in New Issue
Block a user