Patch 9.0.1324
Problem:    "gj" and "gk" do not move correctly over a closed fold.
Solution:   Use the same code as used for "j"/"k" to go to the next/previous
            line. (Luuk van Baal, closes #12007)
Files:      src/normal.c, src/testdir/test_fold.vim


*** ../vim-9.0.1323/src/normal.c        2023-02-14 17:41:15.774305998 +0000
--- src/normal.c        2023-02-18 20:12:05.162512055 +0000
***************
*** 2344,2363 ****
            else
            {
                // to previous line
! #ifdef FEAT_FOLDING
!               // Move to the start of a closed fold.  Don't do that when
!               // 'foldopen' contains "all": it will open in a moment.
!               if (!(fdo_flags & FDO_ALL))
!                   (void)hasFolding(curwin->w_cursor.lnum,
!                                               &curwin->w_cursor.lnum, NULL);
! #endif
!               if (curwin->w_cursor.lnum == 1)
                {
                    retval = FAIL;
                    break;
                }
-               --curwin->w_cursor.lnum;
- 
                linelen = linetabsize_str(ml_get_curline());
                if (linelen > width1)
                    curwin->w_curswant += (((linelen - width1 - 1) / width2)
--- 2344,2354 ----
            else
            {
                // to previous line
!               if (!cursor_up_inner(curwin, 1))
                {
                    retval = FAIL;
                    break;
                }
                linelen = linetabsize_str(ml_get_curline());
                if (linelen > width1)
                    curwin->w_curswant += (((linelen - width1 - 1) / width2)
***************
*** 2380,2396 ****
            else
            {
                // to next line
! #ifdef FEAT_FOLDING
!               // Move to the end of a closed fold.
!               (void)hasFolding(curwin->w_cursor.lnum, NULL,
!                                                     &curwin->w_cursor.lnum);
! #endif
!               if (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count)
                {
                    retval = FAIL;
                    break;
                }
-               curwin->w_cursor.lnum++;
                curwin->w_curswant %= width2;
                // Check if the cursor has moved below the number display
                // when width1 < width2 (with cpoptions+=n). Subtract width2
--- 2371,2381 ----
            else
            {
                // to next line
!               if (!cursor_down_inner(curwin, 1))
                {
                    retval = FAIL;
                    break;
                }
                curwin->w_curswant %= width2;
                // Check if the cursor has moved below the number display
                // when width1 < width2 (with cpoptions+=n). Subtract width2
*** ../vim-9.0.1323/src/testdir/test_fold.vim   2023-01-28 19:18:56.729720605 
+0000
--- src/testdir/test_fold.vim   2023-02-18 20:12:05.162512055 +0000
***************
*** 1748,1751 ****
--- 1748,1758 ----
    bwipe!
  endfunc
  
+ func Test_fold_screenrow_motion()
+   call setline(1, repeat(['aaaa'], 5))
+   1,4fold
+   norm Ggkzo
+   call assert_equal(1, line('.'))
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.1323/src/version.c       2023-02-18 19:49:28.126600526 +0000
--- src/version.c       2023-02-18 20:15:07.446065584 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1324,
  /**/

-- 
We are the Borg of GNU GPL.  We will assimilate your source code.
Resistance is futile.

 /// 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/20230218201624.843501C0857%40moolenaar.net.

Raspunde prin e-mail lui