mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 06:16:40 +02:00
Fix bug with nick completion (too many nick completors were added to nick if private was open with nick)
This commit is contained in:
@@ -307,6 +307,8 @@ void
|
||||
gui_completion_list_add (struct t_gui_completion *completion, const char *word,
|
||||
int nick_completion, const char *where)
|
||||
{
|
||||
char buffer[512];
|
||||
|
||||
if (!word || !word[0])
|
||||
return;
|
||||
|
||||
@@ -316,8 +318,18 @@ gui_completion_list_add (struct t_gui_completion *completion, const char *word,
|
||||
|| (!nick_completion && (string_strncasecmp (completion->base_word, word,
|
||||
strlen (completion->base_word)) == 0)))
|
||||
{
|
||||
weelist_add (completion->completion_list, word, where,
|
||||
(nick_completion) ? (void *)1 : (void *)0);
|
||||
if (nick_completion && (completion->base_word_pos == 0))
|
||||
{
|
||||
snprintf (buffer, sizeof (buffer), "%s%s",
|
||||
word, CONFIG_STRING(config_completion_nick_completor));
|
||||
weelist_add (completion->completion_list, buffer, where,
|
||||
(nick_completion) ? (void *)1 : (void *)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
weelist_add (completion->completion_list, word, where,
|
||||
(nick_completion) ? (void *)1 : (void *)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1724,6 +1736,7 @@ gui_completion_print_log (struct t_gui_completion *completion)
|
||||
log_printf (" force_partial_completion: %d", completion->force_partial_completion);
|
||||
log_printf (" completion_list . . . . : 0x%lx", completion->completion_list);
|
||||
log_printf (" word_found. . . . . . . : '%s'", completion->word_found);
|
||||
log_printf (" word_found_is_nick. . . : %d", completion->word_found_is_nick);
|
||||
log_printf (" position_replace. . . . : %d", completion->position_replace);
|
||||
log_printf (" diff_size . . . . . . . : %d", completion->diff_size);
|
||||
log_printf (" diff_length . . . . . . : %d", completion->diff_length);
|
||||
|
||||
+10
-40
@@ -363,47 +363,17 @@ gui_input_complete (struct t_gui_buffer *buffer)
|
||||
buffer->completion->position = utf8_real_pos (buffer->input_buffer,
|
||||
buffer->input_buffer_pos);
|
||||
|
||||
/* add nick completor if position 0 and completing nick */
|
||||
if ((buffer->completion->base_word_pos == 0)
|
||||
&& buffer->completion->word_found_is_nick)
|
||||
/* add space if needed after completion */
|
||||
if (buffer->completion->add_space)
|
||||
{
|
||||
if (buffer->completion->add_space)
|
||||
{
|
||||
if (strncmp (utf8_add_offset (buffer->input_buffer,
|
||||
buffer->input_buffer_pos),
|
||||
CONFIG_STRING(config_completion_nick_completor),
|
||||
strlen (CONFIG_STRING(config_completion_nick_completor))) != 0)
|
||||
gui_input_insert_string (buffer,
|
||||
CONFIG_STRING(config_completion_nick_completor),
|
||||
buffer->input_buffer_pos);
|
||||
else
|
||||
buffer->input_buffer_pos += utf8_strlen (CONFIG_STRING(config_completion_nick_completor));
|
||||
if (buffer->completion->position >= 0)
|
||||
buffer->completion->position += strlen (CONFIG_STRING(config_completion_nick_completor));
|
||||
if (buffer->input_buffer[utf8_real_pos (buffer->input_buffer,
|
||||
buffer->input_buffer_pos)] != ' ')
|
||||
gui_input_insert_string (buffer, " ",
|
||||
buffer->input_buffer_pos);
|
||||
else
|
||||
buffer->input_buffer_pos++;
|
||||
if (buffer->completion->position >= 0)
|
||||
buffer->completion->position++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add space or completor to the end of completion, if needed */
|
||||
if (buffer->completion->add_space)
|
||||
{
|
||||
if (buffer->input_buffer[utf8_real_pos (buffer->input_buffer,
|
||||
buffer->input_buffer_pos)] != ' ')
|
||||
gui_input_insert_string (buffer, " ",
|
||||
buffer->input_buffer_pos);
|
||||
else
|
||||
buffer->input_buffer_pos++;
|
||||
if (buffer->completion->position >= 0)
|
||||
buffer->completion->position++;
|
||||
}
|
||||
if (buffer->input_buffer[utf8_real_pos (buffer->input_buffer,
|
||||
buffer->input_buffer_pos)] != ' ')
|
||||
gui_input_insert_string (buffer, " ",
|
||||
buffer->input_buffer_pos);
|
||||
else
|
||||
buffer->input_buffer_pos++;
|
||||
if (buffer->completion->position >= 0)
|
||||
buffer->completion->position++;
|
||||
}
|
||||
gui_input_text_changed_modifier_and_signal (buffer);
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item,
|
||||
/* remote nick */
|
||||
weechat_hook_completion_list_add (completion,
|
||||
ptr_channel->name,
|
||||
0,
|
||||
1,
|
||||
WEECHAT_LIST_POS_SORT);
|
||||
/* add self nick at the end */
|
||||
weechat_hook_completion_list_add (completion,
|
||||
@@ -310,7 +310,7 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item,
|
||||
case IRC_CHANNEL_TYPE_PRIVATE:
|
||||
weechat_hook_completion_list_add (completion,
|
||||
ptr_channel->name,
|
||||
0,
|
||||
1,
|
||||
WEECHAT_LIST_POS_SORT);
|
||||
break;
|
||||
}
|
||||
@@ -373,8 +373,11 @@ irc_completion_channels_cb (void *data, const char *completion_item,
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_channel->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_channel->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user