# HG changeset patch # User Bram Moolenaar # Date 1569358805 -7200 # Node ID 5e10ee16f4b4371e8b3b77a301fef37a4e5ca79a # Parent 15be611fcb05ddd017a61e76974f87a2fe76f778 patch 8.1.2072: "gk" moves to start of line instead of upwards Commit: https://github.com/vim/vim/commit/03ac52fc025790c474030ea556cec799400aa046 Author: Bram Moolenaar Date: Tue Sep 24 22:47:46 2019 +0200 patch 8.1.2072: "gk" moves to start of line instead of upwards Problem: "gk" moves to start of line instead of upwards. Solution: Fix off-by-one error. (Christian Brabandt, closes https://github.com/vim/vim/issues/4969) diff --git a/src/normal.c b/src/normal.c --- a/src/normal.c +++ b/src/normal.c @@ -3406,8 +3406,8 @@ nv_screengo(oparg_T *oap, int dir, long { if (dir == BACKWARD) { - if ((long)curwin->w_curswant >= width2) - /* move back within line */ + if ((long)curwin->w_curswant > width2) + // move back within line curwin->w_curswant -= width2; else { diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -2633,3 +2633,25 @@ fun! Test_normal_gdollar_cmd() call assert_equal('100 foobar foobar fo', getreg(0)) bw! endfunc + +func Test_normal_gk() + " needs 80 column new window + new + vert 80new + put =[repeat('x',90)..' {{{1', 'x {{{1'] + norm! gk + " In a 80 column wide terminal the window will be only 78 char + " (because Vim will leave space for the other window), + " but if the terminal is larger, it will be 80 chars, so verify the + " cursor column correctly. + call assert_equal(winwidth(0)+1, col('.')) + call assert_equal(winwidth(0)+1, virtcol('.')) + norm! j + call assert_equal(6, col('.')) + call assert_equal(6, virtcol('.')) + norm! gk + call assert_equal(95, col('.')) + call assert_equal(95, virtcol('.')) + bw! + bw! +endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2072, +/**/ 2071, /**/ 2070,