Patch 9.0.0673
Problem:    First line not scrolled properly with 'smoothscroll' and
            'scrolloff' zero and using "k".
Solution:   Make sure the cursor position is visible.
Files:      src/move.c, src/testdir/test_scroll_opt.vim,
            src/testdir/dumps/Test_smooth_wrap_5.dump


*** ../vim-9.0.0672/src/move.c  2022-10-06 14:57:29.651338532 +0100
--- src/move.c  2022-10-06 15:38:52.678152619 +0100
***************
*** 266,272 ****
       */
      else
      {
!       if (curwin->w_topline > 1)
        {
            // If the cursor is above topline, scrolling is always needed.
            // If the cursor is far below topline and there is no folding,
--- 266,272 ----
       */
      else
      {
!       if (curwin->w_topline > 1 || curwin->w_skipcol > 0)
        {
            // If the cursor is above topline, scrolling is always needed.
            // If the cursor is far below topline and there is no folding,
***************
*** 275,280 ****
--- 275,290 ----
                check_topline = TRUE;
            else if (check_top_offset())
                check_topline = TRUE;
+           else if (curwin->w_cursor.lnum == curwin->w_topline)
+           {
+               colnr_T vcol;
+ 
+               // check the cursor position is visible.  Add 3 for the ">>>"
+               // displayed in the top-left.
+               getvvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
+               if (curwin->w_skipcol + 3 >= vcol)
+                   check_topline = TRUE;
+           }
        }
  #ifdef FEAT_DIFF
            // Check if there are more filler lines than allowed.
***************
*** 2007,2012 ****
--- 2017,2023 ----
      linenr_T  top;            // just above displayed lines
      linenr_T  bot;            // just below displayed lines
      linenr_T  old_topline = curwin->w_topline;
+     int               old_skipcol = curwin->w_skipcol;
  #ifdef FEAT_DIFF
      linenr_T  old_topfill = curwin->w_topfill;
  #endif
***************
*** 2118,2124 ****
--- 2129,2142 ----
        }
        check_topfill(curwin, FALSE);
  #endif
+       // TODO: if the line doesn't fit may optimize w_skipcol
+       if (curwin->w_topline == curwin->w_cursor.lnum)
+       {
+           curwin->w_skipcol = 0;
+           redraw_later(UPD_NOT_VALID);
+       }
        if (curwin->w_topline != old_topline
+               || curwin->w_skipcol != old_skipcol
  #ifdef FEAT_DIFF
                || curwin->w_topfill != old_topfill
  #endif
*** ../vim-9.0.0672/src/testdir/test_scroll_opt.vim     2022-10-06 
14:57:29.651338532 +0100
--- src/testdir/test_scroll_opt.vim     2022-10-06 15:41:22.857399383 +0100
***************
*** 181,186 ****
--- 181,187 ----
  
    call VerifyScreenDump(buf, 'Test_smooth_wrap_1', {})
  
+   " moving cursor down - whole bottom line shows
    call term_sendkeys(buf, "j")
    call VerifyScreenDump(buf, 'Test_smooth_wrap_2', {})
  
***************
*** 190,195 ****
--- 191,200 ----
    call term_sendkeys(buf, "G")
    call VerifyScreenDump(buf, 'Test_smooth_wrap_4', {})
  
+   " moving cursor up - whole top line shows
+   call term_sendkeys(buf, "2k")
+   call VerifyScreenDump(buf, 'Test_smooth_wrap_5', {})
+ 
    call StopVimInTerminal(buf)
  endfunc
  
*** ../vim-9.0.0672/src/testdir/dumps/Test_smooth_wrap_5.dump   2022-10-06 
15:44:08.188721470 +0100
--- src/testdir/dumps/Test_smooth_wrap_5.dump   2022-10-06 15:41:29.441369658 
+0100
***************
*** 0 ****
--- 1,8 ----
+ >L+0&#ffffff0|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| 
|t|e|x|t| |w|i|t|h| 
+ |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| 
|t|e|x|t| 
+ |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+ |L|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| 
|w|i|t|h| 
+ |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| 
|t|e|x|t| 
+ |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+ |@+0#4040ff13&@2| @36
+ | +0#0000000&@21|5|,|1| @10|8|0|%| 
*** ../vim-9.0.0672/src/version.c       2022-10-06 14:57:29.651338532 +0100
--- src/version.c       2022-10-06 15:44:14.476698216 +0100
***************
*** 701,702 ****
--- 701,704 ----
  {   /* Add new patch number below this line */
+ /**/
+     673,
  /**/

-- 
FIRST HEAD: All right! All right! We'll kill him first and then have tea and
            biscuits.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221006144725.82A571C0C31%40moolenaar.net.

Raspunde prin e-mail lui