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 41068c77aa)
This commit is contained in:
zeertzjq
2026-01-18 11:46:13 +08:00
committed by github-actions[bot]
parent 1db945b584
commit 6ef1b655fe
2 changed files with 8 additions and 1 deletions

View File

@@ -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;
}
}

View File

@@ -59,4 +59,11 @@ describe('Normal mode', function()
|
]])
end)
it('"gk" does not crash with signcolumn=yes in narrow window #31274', function()
feed('o<Esc>')
command('1vsplit | setlocal signcolumn=yes')
feed('gk')
n.assert_alive()
end)
end)