]> granicus.if.org Git - vim/commitdiff
patch 8.1.2072: "gk" moves to start of line instead of upwards v8.1.2072
authorBram Moolenaar <Bram@vim.org>
Tue, 24 Sep 2019 20:47:46 +0000 (22:47 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 24 Sep 2019 20:47:46 +0000 (22:47 +0200)
Problem:    "gk" moves to start of line instead of upwards.
Solution:   Fix off-by-one error. (Christian Brabandt, closes #4969)

src/normal.c
src/testdir/test_normal.vim
src/version.c

index adc7541b1b9a5aa8035b268f9328958299c0f0f8..4db90d658fb136aa1208eeb7f1f0060a603de6fe 100644 (file)
@@ -3406,8 +3406,8 @@ nv_screengo(oparg_T *oap, int dir, long dist)
       {
        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
            {
index c6df1834a2f6ebf6fcc7f3667bf9012b0e11997d..dcfa929c8a4b636188932b96e500439307a94794 100644 (file)
@@ -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
index 840c257358bdfeb73e09de2e0bf17f4599631ec3..ec9aa76635c5cbbe8d8542acde77c5238d38ab60 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2072,
 /**/
     2071,
 /**/