patch 9.1.0407: Stuck with long line and half-page scrolling

Commit: 
https://github.com/vim/vim/commit/58448e09be497a8abb595ae309b6edfbc8e0e05a
Author: Luuk van Baal <luukvb...@gmail.com>
Date:   Sat May 11 11:27:52 2024 +0200

    patch 9.1.0407: Stuck with long line and half-page scrolling
    
    Problem:  No scrolling happens with half-page scrolling with line
              filling entire window when 'smoothscroll' is disabled.
              (Mathias Rav, after v9.1.0285)
    Solution: Adjust amount to move cursor by so that it is moved the same
              number of lines as was scrolled, even when scrolling different
              number of lines than requested with 'nosmoothscroll'.
    
    fixes: #14743
    closes: #14746
    
    Signed-off-by: Luuk van Baal <luukvb...@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/move.c b/src/move.c
index 797184812..3e589caae 100644
--- a/src/move.c
+++ b/src/move.c
@@ -3158,9 +3158,10 @@ static int get_scroll_overlap(int dir)
 
 /*
  * Scroll "count" lines with 'smoothscroll' in direction "dir". Return TRUE
- * when scrolling happened.
+ * when scrolling happened. Adjust "curscount" for scrolling different amount 
of
+ * lines when 'smoothscroll' is disabled.
  */
-static int scroll_with_sms(int dir, long count)
+static int scroll_with_sms(int dir, long count, long *curscount)
 {
     int                prev_sms = curwin->w_p_sms;
     colnr_T    prev_skipcol = curwin->w_skipcol;
@@ -3183,7 +3184,10 @@ static int scroll_with_sms(int dir, long count)
            fixdir = dir * -1;
        while (curwin->w_skipcol > 0
            && curwin->w_topline < curbuf->b_ml.ml_line_count)
+       {
            scroll_redraw(fixdir == FORWARD, 1);
+           *curscount += (fixdir == dir ? 1 : -1);
+       }
     }
     curwin->w_p_sms = prev_sms;
 
@@ -3220,7 +3224,7 @@ pagescroll(int dir, long count, int half)
            curwin->w_p_scr = MIN(curwin->w_height, count);
        count = MIN(curwin->w_height, curwin->w_p_scr);
 
-       int curscount = count;
+       long curscount = count;
        // Adjust count so as to not reveal end of buffer lines.
        if (dir == FORWARD
                    && (curwin->w_topline + curwin->w_height + count > buflen
@@ -3240,7 +3244,7 @@ pagescroll(int dir, long count, int half)
        // (Try to) scroll the window unless already at the end of the buffer.
        if (count > 0)
        {
-           nochange = scroll_with_sms(dir, count);
+           nochange = scroll_with_sms(dir, count, &curscount);
            curwin->w_cursor.lnum = prev_lnum;
            curwin->w_cursor.col = prev_col;
            curwin->w_curswant = prev_curswant;
@@ -3259,7 +3263,7 @@ pagescroll(int dir, long count, int half)
        // Scroll [count] times 'window' or current window height lines.
        count *= ((ONE_WINDOW && p_window > 0 && p_window < Rows - 1) ?
                                MAX(1, p_window - 2) : get_scroll_overlap(dir));
-       nochange = scroll_with_sms(dir, count);
+       nochange = scroll_with_sms(dir, count, &count);
 
        // Place cursor at top or bottom of window.
        validate_botline();
diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim
index 4b7e5e614..5cbf681ea 100644
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -4260,4 +4260,12 @@ func Test_page_cursor_topbot()
   bwipe!
 endfunc
 
+" Test for Ctrl-D with long line
+func Test_halfpage_longline()
+  10new
+  call setline(1, ['long'->repeat(1000), 'short'])
+  exe "norm! \<C-D>"
+  call assert_equal(2, line('.'))
+  bwipe!
+endfunc
 " vim: shiftwidth=2 sts=2 expandtab nofoldenable
diff --git a/src/version.c b/src/version.c
index e601c8217..828b3c78b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    407,
 /**/
     406,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1s5jHq-00CARb-WE%40256bit.org.

Raspunde prin e-mail lui