summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/wee-hook.c4
-rw-r--r--src/gui/gui-completion.c23
2 files changed, 19 insertions, 8 deletions
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c
index 15097ccb2..3528d0251 100644
--- a/src/core/wee-hook.c
+++ b/src/core/wee-hook.c
@@ -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);
}
diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c
index 8078e6a45..affe2841c 100644
--- a/src/gui/gui-completion.c
+++ b/src/gui/gui-completion.c
@@ -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):