Patch 8.1.0034
Problem:    Cursor not restored with ":edit #".
Solution:   Don't assume autocommands moved the cursor when it was moved to
            the first non-blank.
Files:      src/ex_cmds.c, src/testdir/test_edit.vim


*** ../vim-8.1.0033/src/ex_cmds.c       2018-04-10 18:37:19.000000000 +0200
--- src/ex_cmds.c       2018-06-04 20:28:56.647447774 +0200
***************
*** 4193,4203 ****
        check_arg_idx(curwin);
  
        /* If autocommands change the cursor position or topline, we should
!        * keep it.  Also when it moves within a line. */
        if (!EQUAL_POS(curwin->w_cursor, orig_pos))
        {
!           newlnum = curwin->w_cursor.lnum;
!           newcol = curwin->w_cursor.col;
        }
        if (curwin->w_topline == topline)
            topline = 0;
--- 4193,4210 ----
        check_arg_idx(curwin);
  
        /* If autocommands change the cursor position or topline, we should
!        * keep it.  Also when it moves within a line. But not when it moves
!        * to the first non-blank. */
        if (!EQUAL_POS(curwin->w_cursor, orig_pos))
        {
!           char_u *text = ml_get_curline();
! 
!           if (curwin->w_cursor.lnum != orig_pos.lnum
!                   || curwin->w_cursor.col != (int)(skipwhite(text) - text))
!           {
!               newlnum = curwin->w_cursor.lnum;
!               newcol = curwin->w_cursor.col;
!           }
        }
        if (curwin->w_topline == topline)
            topline = 0;
*** ../vim-8.1.0033/src/testdir/test_edit.vim   2018-02-09 14:37:30.000000000 
+0100
--- src/testdir/test_edit.vim   2018-06-04 20:28:56.647447774 +0200
***************
*** 1387,1389 ****
--- 1387,1403 ----
    only
  endfunc
  
+ func Test_edit_alt()
+   " Keeping the cursor line didn't happen when the first line has indent.
+   new
+   call setline(1, ['  one', 'two', 'three'])
+   w XAltFile
+   $
+   call assert_equal(3, line('.'))
+   e Xother
+   e #
+   call assert_equal(3, line('.'))
+ 
+   bwipe XAltFile
+   call delete('XAltFile')
+ endfunc
*** ../vim-8.1.0033/src/version.c       2018-06-04 19:11:06.604648995 +0200
--- src/version.c       2018-06-04 20:31:05.227428478 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     34,
  /**/

-- 
How To Keep A Healthy Level Of Insanity:
8. Don't use any punctuation marks.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui