summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-04-19 20:57:28 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-04-20 22:36:18 +0200
commit078da85f5e2111a50336f89081e2133283cf44d8 (patch)
tree2f452cc1f4e488dccc5ccea029947fdbc534936a
parent5193c0aeea85e6a11619c0bb7951b181ac1d1d54 (diff)
downloadweechat-078da85f5e2111a50336f89081e2133283cf44d8.zip
core: keep only first message line in hdata update of line_data when input_multiline is not set in buffer
-rw-r--r--src/gui/gui-line.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c
index 3bfd80c2b..8608bd102 100644
--- a/src/gui/gui-line.c
+++ b/src/gui/gui-line.c
@@ -2147,6 +2147,7 @@ gui_line_hdata_line_data_update_cb (void *data,
struct t_hashtable *hashtable)
{
const char *value;
+ char *new_value, *pos_newline;
struct t_gui_line_data *line_data;
struct t_gui_window *ptr_win;
int rc, update_coords;
@@ -2205,9 +2206,19 @@ gui_line_hdata_line_data_update_cb (void *data,
if (hashtable_has_key (hashtable, "message"))
{
value = hashtable_get (hashtable, "message");
- hdata_set (hdata, pointer, "message", value);
+ new_value = (value) ? strdup (value) : NULL;
+ if (new_value && !line_data->buffer->input_multiline)
+ {
+ /* if input_multiline is not set, keep only first line */
+ pos_newline = strchr (new_value, '\n');
+ if (pos_newline)
+ pos_newline[0] = '\0';
+ }
+ hdata_set (hdata, pointer, "message", new_value);
rc++;
update_coords = 1;
+ if (new_value)
+ free (new_value);
}
if (rc > 0)