]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0526: Unwanted cursor movement with pagescroll at start of buffer v9.1.0526
authorLuuk van Baal <luukvbaal@gmail.com>
Thu, 4 Jul 2024 15:35:56 +0000 (17:35 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 4 Jul 2024 15:35:56 +0000 (17:35 +0200)
Problem:  Cursor is moved to bottom of window trying to pagescroll when
          already at the start of the buffer (Asheq Imran, after v9.1.0357)
Solution: Don't move cursor when buffer content did not move.
          (Luuk van Baal)

closes: #15139

Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/move.c
src/testdir/test_normal.vim
src/version.c

index 71654dd769eec5516b18534ba3dccd341e45bbd7..f2780e584ec43f2e2081398bb21c8ab590f84766 100644 (file)
@@ -3281,10 +3281,13 @@ pagescroll(int dir, long count, int half)
                                MAX(1, p_window - 2) : get_scroll_overlap(dir));
        nochange = scroll_with_sms(dir, count, &count);
 
-       // Place cursor at top or bottom of window.
-       validate_botline();
-       curwin->w_cursor.lnum = (dir == FORWARD ? curwin->w_topline
+       if (!nochange)
+       {
+           // Place cursor at top or bottom of window.
+           validate_botline();
+           curwin->w_cursor.lnum = (dir == FORWARD ? curwin->w_topline
                                                    : curwin->w_botline - 1);
+       }
     }
 
     if (get_scrolloff_value() > 0)
index 83594d202e36bac202f14eee56beee0a34ce16b4..398bf2992f9a233012469d101463dbd153901b7b 100644 (file)
@@ -4257,6 +4257,9 @@ func Test_page_cursor_topbot()
   call assert_equal(18, line('.'))
   exe "norm! \<C-B>\<C-F>"
   call assert_equal(9, line('.'))
+  " Not when already at the start of the buffer.
+  exe "norm! ggj\<C-B>"
+  call assert_equal(2, line('.'))
   bwipe!
 endfunc
 
index 66ed6a6f640ca0808e540d272664bcbc59854f5e..462b094be9f0017656ac167543ba306d2031ad90 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    526,
 /**/
     525,
 /**/