]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0645: CTRL-Y does not stop at line 1 v9.0.0645
authorBram Moolenaar <Bram@vim.org>
Mon, 3 Oct 2022 11:11:13 +0000 (12:11 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 3 Oct 2022 11:11:13 +0000 (12:11 +0100)
Problem:    CTRL-Y does not stop at line 1. (John Marriott)
Solution:   Stop at line 1 when 'smoothscroll' is not set. (closes #11261)

src/move.c
src/testdir/test_scroll_opt.vim
src/version.c

index dca77f787c0b49534d3553e6061f0615e2ad861a..43e3273e2e05d7fc58f7f0a09854d864cb3cb47d 100644 (file)
@@ -1485,11 +1485,14 @@ scrolldown(
        else
 #endif
        {
-           if (curwin->w_topline == 1 && curwin->w_skipcol < width1)
+           // break when at the very top
+           if (curwin->w_topline == 1
+                          && (!curwin->w_p_sms || curwin->w_skipcol < width1))
                break;
            if (curwin->w_p_wrap && curwin->w_p_sms
-                                                 && curwin->w_skipcol >= width1)
+                                               && curwin->w_skipcol >= width1)
            {
+               // scroll a screen line down
                if (curwin->w_skipcol >= width1 + width2)
                    curwin->w_skipcol -= width2;
                else
@@ -1499,6 +1502,7 @@ scrolldown(
            }
            else
            {
+               // scroll a text line down
                --curwin->w_topline;
                curwin->w_skipcol = 0;
 #ifdef FEAT_DIFF
index f034d3a230a4a92fbb4a85425e549c2c5d6d5899..876ccf203a00736d7bf1d7c1300caf6e5333c75a 100644 (file)
@@ -37,6 +37,19 @@ func Test_reset_scroll()
   quit!
 endfunc
 
+func Test_CtrlE_CtrlY_stop_at_end()
+  enew
+  call setline(1, ['one', 'two'])
+  set number
+  exe "normal \<C-Y>"
+  call assert_equal(["  1 one   "], ScreenLines(1, 10))
+  exe "normal \<C-E>\<C-E>\<C-E>"
+  call assert_equal(["  2 two   "], ScreenLines(1, 10))
+
+  bwipe!
+  set nonumber
+endfunc
+
 func Test_smoothscroll_CtrlE_CtrlY()
   CheckScreendump
 
index 32a9851c832e37420b7b87207c702cb2d405c6e5..0cf367ea6ff4973f667c2df8f255885b86d1682d 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    645,
 /**/
     644,
 /**/