Blob Blame History Raw
To: vim-dev@vim.org
Subject: Patch 7.3.020
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.020
Problem:    Cursor position wrong when joining multiple lines and
	    'formatoptions' contains "a". (Moshe Kamensky)
Solution:   Adjust cursor position for skipped indent. (Carlo Teubner)
Files:	    src/ops.c, src/testdir/test68.in, src/testdir/test68.ok


*** ../vim-7.3.019/src/ops.c	2010-08-15 21:57:28.000000000 +0200
--- src/ops.c	2010-10-09 17:00:35.000000000 +0200
***************
*** 4153,4161 ****
      int	    save_undo;
  {
      char_u	*curr = NULL;
      char_u	*cend;
      char_u	*newp;
!     char_u	*spaces;	/* number of spaces inserte before a line */
      int		endcurr1 = NUL;
      int		endcurr2 = NUL;
      int		currsize = 0;	/* size of the current line */
--- 4153,4162 ----
      int	    save_undo;
  {
      char_u	*curr = NULL;
+     char_u      *curr_start = NULL;
      char_u	*cend;
      char_u	*newp;
!     char_u	*spaces;	/* number of spaces inserted before a line */
      int		endcurr1 = NUL;
      int		endcurr2 = NUL;
      int		currsize = 0;	/* size of the current line */
***************
*** 4181,4187 ****
       */
      for (t = 0; t < count; ++t)
      {
! 	curr = ml_get((linenr_T)(curwin->w_cursor.lnum + t));
  	if (insert_space && t > 0)
  	{
  	    curr = skipwhite(curr);
--- 4182,4188 ----
       */
      for (t = 0; t < count; ++t)
      {
! 	curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t));
  	if (insert_space && t > 0)
  	{
  	    curr = skipwhite(curr);
***************
*** 4265,4274 ****
  	    copy_spaces(cend, (size_t)(spaces[t]));
  	}
  	mark_col_adjust(curwin->w_cursor.lnum + t, (colnr_T)0, (linenr_T)-t,
! 				 (long)(cend - newp + spaces[t]));
  	if (t == 0)
  	    break;
! 	curr = ml_get((linenr_T)(curwin->w_cursor.lnum + t - 1));
  	if (insert_space && t > 1)
  	    curr = skipwhite(curr);
  	currsize = (int)STRLEN(curr);
--- 4266,4275 ----
  	    copy_spaces(cend, (size_t)(spaces[t]));
  	}
  	mark_col_adjust(curwin->w_cursor.lnum + t, (colnr_T)0, (linenr_T)-t,
! 			 (long)(cend - newp + spaces[t] - (curr - curr_start)));
  	if (t == 0)
  	    break;
! 	curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t - 1));
  	if (insert_space && t > 1)
  	    curr = skipwhite(curr);
  	currsize = (int)STRLEN(curr);
*** ../vim-7.3.019/src/testdir/test68.in	2010-08-15 21:57:29.000000000 +0200
--- src/testdir/test68.in	2010-10-09 16:53:02.000000000 +0200
***************
*** 51,56 ****
--- 51,67 ----
  }
  
  STARTTEST
+ /^{/+2
+ :set tw& fo=a
+ I^^
+ ENDTEST
+ 
+ {
+    1aa
+    2bb
+ }
+ 
+ STARTTEST
  :g/^STARTTEST/.,/^ENDTEST/d
  :1;/^Results/,$wq! test.out
  ENDTEST
*** ../vim-7.3.019/src/testdir/test68.ok	2010-08-15 21:57:29.000000000 +0200
--- src/testdir/test68.ok	2010-10-09 16:53:02.000000000 +0200
***************
*** 33,35 ****
--- 33,38 ----
  #a b
  }
  
+ 
+ { 1aa ^^2bb }
+ 
*** ../vim-7.3.019/src/version.c	2010-09-30 21:03:13.000000000 +0200
--- src/version.c	2010-10-09 17:05:31.000000000 +0200
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     20,
  /**/

-- 
Did you hear about the new 3 million dollar West Virginia State Lottery?
The winner gets 3 dollars a year for a million years.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///