diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 309f88428a..bbf4f5960c 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2562,7 +2562,7 @@ bool nv_screengo(oparg_T *oap, int dir, int dist, bool skip_conceal) linelen = linetabsize(curwin, curwin->w_cursor.lnum); if (linelen > width1) { int w = (((linelen - width1 - 1) / width2) + 1) * width2; - assert(curwin->w_curswant <= INT_MAX - w); + assert(w <= 0 || curwin->w_curswant <= INT_MAX - w); curwin->w_curswant += w; } } diff --git a/test/functional/editor/mode_normal_spec.lua b/test/functional/editor/mode_normal_spec.lua index 353a261edb..c3ffa2cfed 100644 --- a/test/functional/editor/mode_normal_spec.lua +++ b/test/functional/editor/mode_normal_spec.lua @@ -59,4 +59,11 @@ describe('Normal mode', function() | ]]) end) + + it('"gk" does not crash with signcolumn=yes in narrow window #31274', function() + feed('o') + command('1vsplit | setlocal signcolumn=yes') + feed('gk') + n.assert_alive() + end) end)