1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-10 11:43:13 +02:00

core: allow incomplete commands if unambiguous (task #5419)

This commit is contained in:
Sébastien Helleu
2014-08-23 12:13:11 +02:00
parent f6c2fd9bce
commit 8c586eb49a
19 changed files with 338 additions and 130 deletions
+27 -9
View File
@@ -224,27 +224,45 @@ struct t_hook *
gui_completion_search_command (struct t_weechat_plugin *plugin,
const char *command)
{
struct t_hook *ptr_hook, *hook_for_other_plugin;
struct t_hook *ptr_hook, *hook_for_other_plugin, *hook_incomplete_command;
int length_command, allow_incomplete_commands, count_incomplete_commands;
hook_for_other_plugin = NULL;
hook_incomplete_command = NULL;
length_command = strlen (command);
count_incomplete_commands = 0;
allow_incomplete_commands = CONFIG_BOOLEAN(config_look_command_incomplete);
for (ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; ptr_hook;
ptr_hook = ptr_hook->next_hook)
{
if (!ptr_hook->deleted
&& HOOK_COMMAND(ptr_hook, command)
&& HOOK_COMMAND(ptr_hook, command)[0]
&& (string_strcasecmp (HOOK_COMMAND(ptr_hook, command),
command) == 0))
&& HOOK_COMMAND(ptr_hook, command)[0])
{
if (ptr_hook->plugin == plugin)
return ptr_hook;
hook_for_other_plugin = ptr_hook;
if (string_strcasecmp (HOOK_COMMAND(ptr_hook, command),
command) == 0)
{
if (ptr_hook->plugin == plugin)
return ptr_hook;
hook_for_other_plugin = ptr_hook;
}
else if (allow_incomplete_commands
&& (string_strncasecmp (HOOK_COMMAND(ptr_hook, command),
command,
length_command) == 0))
{
hook_incomplete_command = ptr_hook;
count_incomplete_commands++;
}
}
}
return hook_for_other_plugin;
if (hook_for_other_plugin)
return hook_for_other_plugin;
return (count_incomplete_commands == 1) ?
hook_incomplete_command : NULL;
}
/*