diff --git a/src/nvim/plines.c b/src/nvim/plines.c index 3925bfbdc0..a2ae392e95 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -814,7 +814,7 @@ int plines_win_nofold(win_T *wp, linenr_T lnum) } /// Like plines_win(), but only reports the number of physical screen lines -/// used from the start of the line to the given column number. +/// used from the start of the line to the given byte column. int plines_win_col(win_T *wp, linenr_T lnum, long column) { // Check for filler lines above this buffer line. @@ -837,12 +837,12 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column) StrCharInfo ci = utf_ptr2StrCharInfo(line); if (cstype == kCharsizeFast) { bool const use_tabstop = csarg.use_tabstop; - while (*ci.ptr != NUL && --column >= 0) { + while (*ci.ptr != NUL && ci.ptr < line + column) { vcol += charsize_fast_impl(wp, ci.ptr, use_tabstop, vcol, ci.chr.value).width; ci = utfc_next(ci); } } else { - while (*ci.ptr != NUL && --column >= 0) { + while (*ci.ptr != NUL && ci.ptr < line + column) { vcol += charsize_regular(&csarg, ci.ptr, vcol, ci.chr.value).width; ci = utfc_next(ci); } diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim index 783829221e..70337df60f 100644 --- a/test/old/testdir/test_window_cmd.vim +++ b/test/old/testdir/test_window_cmd.vim @@ -1989,6 +1989,24 @@ func Test_splitkeep_cmdheight() set splitkeep& cmdheight& endfunc +func Test_aucmd_win_scroll_multibyte() + " Using the autocommand window must not scroll the current window when the + " cursor is behind multi-byte characters. + set splitkeep=cursor + call setline(1, repeat([repeat(nr2char(0x3042), 200)], 20)) + normal! G0100l + redraw + let topline = line('w0') + + for i in range(3) + call bufload(bufadd('')) + endfor + call assert_equal(topline, line('w0')) + + %bwipeout! + set splitkeep& +endfunc + func Test_splitkeep_cursor() CheckScreendump let lines =<< trim END