diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index 1856ff10f..0ec108c38 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -26,6 +26,8 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] === Bugs fixed +* core: fix truncated messages after a word with a length of zero on screen + (for example a zero width space: U+200B) (bug #40985, issue #502) * irc: fix display of messages sent to server in raw buffer * irc: fix display of invalid UTF-8 chars in raw buffer diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index c1cf10a82..0bbd1810e 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -1365,13 +1365,13 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line, ptr_end_offset = ptr_data + word_end_offset; /* if message ends with spaces, display them */ - if ((word_length == 0) && (word_length_with_spaces > 0) + if ((word_length <= 0) && (word_length_with_spaces > 0) && !ptr_data[word_end_offset + 1]) { word_length = word_length_with_spaces; } - if (word_length > 0) + if (word_length >= 0) { line_align = gui_line_get_align (window->buffer, line, 1, (lines_displayed == 0) ? 1 : 0); diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index 163e2d9c0..0c2ced0c7 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -332,7 +332,7 @@ gui_chat_get_word_info (struct t_gui_window *window, *word_start_offset = 0; *word_end_offset = 0; *word_length_with_spaces = 0; - *word_length = 0; + *word_length = -1; start_data = data; @@ -354,6 +354,8 @@ gui_chat_get_word_info (struct t_gui_window *window, *word_end_offset = next_char2 - start_data - 1; char_size_screen = gui_chat_char_size_screen (next_char); (*word_length_with_spaces) += char_size_screen; + if (*word_length < 0) + *word_length = 0; (*word_length) += char_size_screen; } else