diff --git a/src/nvim/move.c b/src/nvim/move.c index 6a6f8149dd..ead2b3b0d3 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1502,11 +1502,11 @@ void adjust_skipcol(void) } else { curwin->w_skipcol -= width1; } - redraw_later(curwin, UPD_NOT_VALID); scrolled = true; - validate_virtcol(); } if (scrolled) { + validate_virtcol(); + redraw_later(curwin, UPD_NOT_VALID); return; // don't scroll in the other direction now } long col = curwin->w_virtcol - curwin->w_skipcol + scrolloff_cols; diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 428b14a68d..5036c10827 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -22,6 +22,7 @@ #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" +#include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option_defs.h" #include "nvim/pos.h" @@ -414,6 +415,7 @@ int bck_word(long count, bool bigword, bool stop) finished: stop = false; } + adjust_skipcol(); return OK; } @@ -518,6 +520,7 @@ int bckend_word(long count, bool bigword, bool eol) } } } + adjust_skipcol(); return OK; } diff --git a/test/functional/legacy/display_spec.lua b/test/functional/legacy/display_spec.lua index feb2662100..482b88eae8 100644 --- a/test/functional/legacy/display_spec.lua +++ b/test/functional/legacy/display_spec.lua @@ -286,17 +286,56 @@ describe('display', function() local screen = Screen.new(75, 8) screen:attach() exec([[ - call setline(1, ['a', 'bbbbb '->repeat(100), 'c']) + call setline(1, ['a', 'b ' .. 'bbbbb'->repeat(150), 'c']) norm $j ]]) screen:expect([[ - <<repeat(100), 'c']) + call setline(1, ['a', 'b ' .. 'bbbbb'->repeat(150), 'c']) norm $j END call writefile(lines, 'XdispCursorLongline', 'D') let buf = RunVimInTerminal('-S XdispCursorLongline', #{rows: 8}) - call VerifyScreenDump(buf, 'Test_display_cursor_long_line', {}) + call VerifyScreenDump(buf, 'Test_display_cursor_long_line_1', {}) + + " FIXME: moving the cursor above the topline does not set w_skipcol + " correctly with cpo+=n and zero scrolloff (curs_columns() extra == 1). + call term_sendkeys(buf, ":set number cpo+=n scrolloff=0\") + call term_sendkeys(buf, '$0') + call VerifyScreenDump(buf, 'Test_display_cursor_long_line_2', {}) + + " Going to the start of the line with "b" did not set w_skipcol correctly + " with 'smoothscroll'. + call term_sendkeys(buf, ":set smoothscroll\") + call term_sendkeys(buf, '$b') + call VerifyScreenDump(buf, 'Test_display_cursor_long_line_3', {}) + " Same for "ge". + call term_sendkeys(buf, '$ge') + call VerifyScreenDump(buf, 'Test_display_cursor_long_line_4', {}) call StopVimInTerminal(buf) endfunc diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim index 13ef4b76df..74c2de81aa 100644 --- a/test/old/testdir/test_scroll_opt.vim +++ b/test/old/testdir/test_scroll_opt.vim @@ -502,7 +502,7 @@ func Test_smoothscroll_cursor_position() " regardless of number and cpo-=n. setl number list listchars=precedes:< cpo-=n call s:check_col_calc(5, 1, 1) - exe "normal 2|\" + exe "normal 3|\h" call s:check_col_calc(6, 1, 18) norm h call s:check_col_calc(5, 2, 17)