summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-11-09 17:55:55 +0100
committerSebastien Helleu <flashcode@flashtux.org>2010-11-09 17:55:55 +0100
commitd3492db093956c63e3e96fc81956ade227f782cb (patch)
treedac937104c391bd590035c38cc018fd9704020e8 /src
parentec38523bb36e14843d6527e51ff1b978d56e4a12 (diff)
downloadweechat-d3492db093956c63e3e96fc81956ade227f782cb.zip
Fix irc topic completion in command /topic when channel topic starts with channel name
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-completion.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c
index 5699afc3c..cf478176a 100644
--- a/src/plugins/irc/irc-completion.c
+++ b/src/plugins/irc/irc-completion.c
@@ -418,7 +418,8 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- char *topic_color;
+ char *topic, *topic_color;
+ int length;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
@@ -428,12 +429,35 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
if (ptr_channel && ptr_channel->topic && ptr_channel->topic[0])
{
- topic_color = irc_color_decode_for_user_entry (ptr_channel->topic);
+ if (weechat_strncasecmp (ptr_channel->topic, ptr_channel->name,
+ strlen (ptr_channel->name)) == 0)
+ {
+ /*
+ * if topic starts with channel name, add another channel name
+ * before topic, so that completion will be:
+ * /topic #test #test is a test channel
+ * instead of
+ * /topic #test is a test channel
+ */
+ length = strlen (ptr_channel->name) + strlen (ptr_channel->topic) + 16;
+ topic = malloc (length + 1);
+ if (topic)
+ {
+ snprintf (topic, length, "%s %s",
+ ptr_channel->name, ptr_channel->topic);
+ }
+ }
+ else
+ topic = strdup (ptr_channel->topic);
+
+ topic_color = irc_color_decode_for_user_entry ((topic) ? topic : ptr_channel->topic);
weechat_hook_completion_list_add (completion,
- (topic_color) ? topic_color : ptr_channel->topic,
+ (topic_color) ? topic_color : ((topic) ? topic : ptr_channel->topic),
0, WEECHAT_LIST_POS_SORT);
if (topic_color)
free (topic_color);
+ if (topic)
+ free (topic);
}
return WEECHAT_RC_OK;