From 6ef1b655fe9ff9e90d78d91b9a7948a05a75ed63 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 18 Jan 2026 11:46:13 +0800 Subject: [PATCH] fix(normal): assertion failure with "gk" in narrow window (#37444) When width1 and width2 are negative the assertion may fail. It seems that adding a negative value to w_curswant won't cause any problems, so just change the assertion. (cherry picked from commit 41068c77aa1b221bc4f4321ac0dfe55e13a9f27f) --- src/nvim/normal.c | 2 +- test/functional/editor/mode_normal_spec.lua | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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)