From 078da85f5e2111a50336f89081e2133283cf44d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 19 Apr 2023 20:57:28 +0200 Subject: core: keep only first message line in hdata update of line_data when input_multiline is not set in buffer --- src/gui/gui-line.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') 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) -- cgit v1.2.3