mirror of
https://github.com/weechat/weechat.git
synced 2026-07-02 15:53:12 +02:00
Fixed completion bug when many commands starts with same letters
This commit is contained in:
+17
-11
@@ -118,7 +118,7 @@ completion_get_command_infos (t_completion *completion,
|
||||
char **template, int *max_arg)
|
||||
{
|
||||
t_weechat_alias *ptr_alias;
|
||||
char *ptr_command, *pos;
|
||||
char *ptr_command, *ptr_command2, *pos;
|
||||
int i, length;
|
||||
#ifdef PLUGINS
|
||||
t_weechat_plugin *ptr_plugin;
|
||||
@@ -138,11 +138,13 @@ completion_get_command_infos (t_completion *completion,
|
||||
else
|
||||
ptr_command = completion->base_command;
|
||||
|
||||
pos = strchr (ptr_command, ' ');
|
||||
ptr_command2 = strdup (ptr_command);
|
||||
if (!ptr_command2)
|
||||
return;
|
||||
|
||||
pos = strchr (ptr_command2, ' ');
|
||||
if (pos)
|
||||
length = pos - ptr_command;
|
||||
else
|
||||
length = strlen (ptr_command);
|
||||
pos[0] = '\0';
|
||||
|
||||
#ifdef PLUGINS
|
||||
/* look for plugin command handler */
|
||||
@@ -153,11 +155,12 @@ completion_get_command_infos (t_completion *completion,
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == HANDLER_COMMAND)
|
||||
&& (ascii_strncasecmp (ptr_handler->command,
|
||||
ptr_command, length) == 0))
|
||||
&& (ascii_strcasecmp (ptr_handler->command,
|
||||
ptr_command2) == 0))
|
||||
{
|
||||
*template = ptr_handler->completion_template;
|
||||
*max_arg = MAX_ARGS;
|
||||
free (ptr_command2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -167,11 +170,12 @@ completion_get_command_infos (t_completion *completion,
|
||||
/* look for WeeChat internal command */
|
||||
for (i = 0; weechat_commands[i].command_name; i++)
|
||||
{
|
||||
if (ascii_strncasecmp (weechat_commands[i].command_name,
|
||||
ptr_command, length) == 0)
|
||||
if (ascii_strcasecmp (weechat_commands[i].command_name,
|
||||
ptr_command2) == 0)
|
||||
{
|
||||
*template = weechat_commands[i].completion_template;
|
||||
*max_arg = weechat_commands[i].max_arg;
|
||||
free (ptr_command2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -180,15 +184,17 @@ completion_get_command_infos (t_completion *completion,
|
||||
for (i = 0; irc_commands[i].command_name; i++)
|
||||
{
|
||||
if ((irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg)
|
||||
&& (ascii_strncasecmp (irc_commands[i].command_name,
|
||||
ptr_command, length) == 0))
|
||||
&& (ascii_strcasecmp (irc_commands[i].command_name,
|
||||
ptr_command2) == 0))
|
||||
{
|
||||
*template = irc_commands[i].completion_template;
|
||||
*max_arg = irc_commands[i].max_arg;
|
||||
free (ptr_command2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
free (ptr_command2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ completion_get_command_infos (t_completion *completion,
|
||||
char **template, int *max_arg)
|
||||
{
|
||||
t_weechat_alias *ptr_alias;
|
||||
char *ptr_command, *pos;
|
||||
char *ptr_command, *ptr_command2, *pos;
|
||||
int i, length;
|
||||
#ifdef PLUGINS
|
||||
t_weechat_plugin *ptr_plugin;
|
||||
@@ -138,11 +138,13 @@ completion_get_command_infos (t_completion *completion,
|
||||
else
|
||||
ptr_command = completion->base_command;
|
||||
|
||||
pos = strchr (ptr_command, ' ');
|
||||
ptr_command2 = strdup (ptr_command);
|
||||
if (!ptr_command2)
|
||||
return;
|
||||
|
||||
pos = strchr (ptr_command2, ' ');
|
||||
if (pos)
|
||||
length = pos - ptr_command;
|
||||
else
|
||||
length = strlen (ptr_command);
|
||||
pos[0] = '\0';
|
||||
|
||||
#ifdef PLUGINS
|
||||
/* look for plugin command handler */
|
||||
@@ -153,11 +155,12 @@ completion_get_command_infos (t_completion *completion,
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == HANDLER_COMMAND)
|
||||
&& (ascii_strncasecmp (ptr_handler->command,
|
||||
ptr_command, length) == 0))
|
||||
&& (ascii_strcasecmp (ptr_handler->command,
|
||||
ptr_command2) == 0))
|
||||
{
|
||||
*template = ptr_handler->completion_template;
|
||||
*max_arg = MAX_ARGS;
|
||||
free (ptr_command2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -167,11 +170,12 @@ completion_get_command_infos (t_completion *completion,
|
||||
/* look for WeeChat internal command */
|
||||
for (i = 0; weechat_commands[i].command_name; i++)
|
||||
{
|
||||
if (ascii_strncasecmp (weechat_commands[i].command_name,
|
||||
ptr_command, length) == 0)
|
||||
if (ascii_strcasecmp (weechat_commands[i].command_name,
|
||||
ptr_command2) == 0)
|
||||
{
|
||||
*template = weechat_commands[i].completion_template;
|
||||
*max_arg = weechat_commands[i].max_arg;
|
||||
free (ptr_command2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -180,15 +184,17 @@ completion_get_command_infos (t_completion *completion,
|
||||
for (i = 0; irc_commands[i].command_name; i++)
|
||||
{
|
||||
if ((irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg)
|
||||
&& (ascii_strncasecmp (irc_commands[i].command_name,
|
||||
ptr_command, length) == 0))
|
||||
&& (ascii_strcasecmp (irc_commands[i].command_name,
|
||||
ptr_command2) == 0))
|
||||
{
|
||||
*template = irc_commands[i].completion_template;
|
||||
*max_arg = irc_commands[i].max_arg;
|
||||
free (ptr_command2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
free (ptr_command2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user