summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-05-01 14:53:59 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-05-01 14:53:59 +0200
commit66d79e2d23ef121b8929930f30278979f333ef3e (patch)
tree7f488d206ecf6881a58c12b5d63bb7b7160aaf10 /src
parent9f2e5a98ea8ffbedba199862cc7efabd6e93ea03 (diff)
downloadweechat-66d79e2d23ef121b8929930f30278979f333ef3e.zip
core: keep only first message line in hook line when input_multiline is not set in buffer
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui-line.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c
index 8608bd102..b5cc9b98e 100644
--- a/src/gui/gui-line.c
+++ b/src/gui/gui-line.c
@@ -1574,7 +1574,7 @@ gui_line_hook_update (struct t_gui_line *line,
struct t_gui_buffer *ptr_buffer;
unsigned long value_pointer;
long value;
- char *error;
+ char *error, *new_message, *pos_newline;
int rc, tags_updated, notify_level_updated, highlight_updated;
int max_notify_level;
@@ -1717,9 +1717,19 @@ gui_line_hook_update (struct t_gui_line *line,
ptr_value2 = hashtable_get (hashtable2, "message");
if (ptr_value2 && (!ptr_value || (strcmp (ptr_value, ptr_value2) != 0)))
{
+ new_message = strdup (ptr_value2);
+ if (new_message && !line->data->buffer->input_multiline)
+ {
+ /* if input_multiline is not set, keep only first line */
+ pos_newline = strchr (new_message, '\n');
+ if (pos_newline)
+ pos_newline[0] = '\0';
+ }
if (line->data->message)
free (line->data->message);
- line->data->message = (ptr_value2) ? strdup (ptr_value2) : NULL;
+ line->data->message = (new_message) ? strdup (new_message) : NULL;
+ if (new_message)
+ free (new_message);
}
max_notify_level = gui_line_get_max_notify_level (line);