aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/message.c7
-rw-r--r--src/nvim/testdir/test_utf8.vim11
2 files changed, 16 insertions, 2 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c
index f76a408481..ad38e6d060 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -1711,8 +1711,11 @@ void msg_prt_line(char_u *s, int list)
} else if ((l = utfc_ptr2len(s)) > 1) {
col += utf_ptr2cells(s);
char buf[MB_MAXBYTES + 1];
- if (curwin->w_p_lcs_chars.nbsp != NUL && list
- && (utf_ptr2char(s) == 160 || utf_ptr2char(s) == 0x202f)) {
+ if (l >= MB_MAXBYTES) {
+ xstrlcpy(buf, "¿", sizeof(buf));
+ } else if (curwin->w_p_lcs_chars.nbsp != NUL && list
+ && (utf_ptr2char(s) == 160
+ || utf_ptr2char(s) == 0x202f)) {
utf_char2bytes(curwin->w_p_lcs_chars.nbsp, (char_u *)buf);
buf[utfc_ptr2len((char_u *)buf)] = NUL;
} else {
diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim
index 8302ccb67f..e8161f8fcb 100644
--- a/src/nvim/testdir/test_utf8.vim
+++ b/src/nvim/testdir/test_utf8.vim
@@ -103,3 +103,14 @@ func Test_list2str_str2list_latin1()
call assert_equal(l, lres)
call assert_equal(s, sres)
endfunc
+
+func Test_print_overlong()
+ " Text with more composing characters than MB_MAXBYTES.
+ new
+ call setline(1, 'axxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
+ s/x/\=nr2char(1629)/g
+ print
+ bwipe!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab