diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 929e3f1102..7f50a8e3e6 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -2623,7 +2623,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, b wlv.n_attr = 1; mb_c = schar_get_first_codepoint(mb_schar); } else if (mb_schar != NUL) { - wlv.p_extra = transchar_buf(wp->w_buffer, mb_c); + xstrlcpy(wlv.extra, transchar_buf(wp->w_buffer, mb_c), sizeof(wlv.extra)); + wlv.p_extra = wlv.extra; if (wlv.n_extra == 0) { wlv.n_extra = byte2cells(mb_c) - 1; } diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 33d04e2e56..76bdcc32c9 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -1130,4 +1130,21 @@ describe('statuscolumn', function() | ]]) end) + + it('does not break wrapping at unprintable chars #41198', function() + command([[let &statuscolumn = repeat(' ', 4)]]) + api.nvim_buf_set_lines(0, 0, -1, true, { ('\1'):rep(100), 'foo', 'bar' }) + command('normal! zb') + screen:expect([[ + {8: }{18:^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^}| + {8: }{18:A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A}| + {8: }{18:^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^}| + {8: }{18:A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A^A}| + {8: }{18:^A^A} | + {8: }foo | + {8: }^bar | + {1:~ }|*6 + | + ]]) + end) end)