jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone
dcaee6
To: vim_dev@googlegroups.com
dcaee6
Subject: Patch 7.4.052
dcaee6
Fcc: outbox
dcaee6
From: Bram Moolenaar <Bram@moolenaar.net>
dcaee6
Mime-Version: 1.0
dcaee6
Content-Type: text/plain; charset=UTF-8
dcaee6
Content-Transfer-Encoding: 8bit
dcaee6
------------
dcaee6
dcaee6
Patch 7.4.052
dcaee6
Problem:    With 'fo' set to "a2" inserting a space in the first column may
dcaee6
	    cause the cursor to jump to the previous line.
dcaee6
Solution:   Handle the case when there is no comment leader properly. (Tor
dcaee6
	    Perkins)  Also fix that cursor is in the wrong place when spaces
dcaee6
	    get replaced with a Tab.
dcaee6
Files:	    src/misc1.c, src/ops.c, src/testdir/test68.in,
dcaee6
	    src/testdir/test68.ok
dcaee6
dcaee6
dcaee6
*** ../vim-7.4.051/src/misc1.c	2013-09-05 21:41:35.000000000 +0200
dcaee6
--- src/misc1.c	2013-10-06 17:46:18.000000000 +0200
dcaee6
***************
dcaee6
*** 303,312 ****
dcaee6
  	ml_replace(curwin->w_cursor.lnum, newline, FALSE);
dcaee6
  	if (flags & SIN_CHANGED)
dcaee6
  	    changed_bytes(curwin->w_cursor.lnum, 0);
dcaee6
! 	/* Correct saved cursor position if it's after the indent. */
dcaee6
! 	if (saved_cursor.lnum == curwin->w_cursor.lnum
dcaee6
! 				&& saved_cursor.col >= (colnr_T)(p - oldline))
dcaee6
! 	    saved_cursor.col += ind_len - (colnr_T)(p - oldline);
dcaee6
  	retval = TRUE;
dcaee6
      }
dcaee6
      else
dcaee6
--- 303,320 ----
dcaee6
  	ml_replace(curwin->w_cursor.lnum, newline, FALSE);
dcaee6
  	if (flags & SIN_CHANGED)
dcaee6
  	    changed_bytes(curwin->w_cursor.lnum, 0);
dcaee6
! 	/* Correct saved cursor position if it is in this line. */
dcaee6
! 	if (saved_cursor.lnum == curwin->w_cursor.lnum)
dcaee6
! 	{
dcaee6
! 	    if (saved_cursor.col >= (colnr_T)(p - oldline))
dcaee6
! 		/* cursor was after the indent, adjust for the number of
dcaee6
! 		 * bytes added/removed */
dcaee6
! 		saved_cursor.col += ind_len - (colnr_T)(p - oldline);
dcaee6
! 	    else if (saved_cursor.col >= (colnr_T)(s - newline))
dcaee6
! 		/* cursor was in the indent, and is now after it, put it back
dcaee6
! 		 * at the start of the indent (replacing spaces with TAB) */
dcaee6
! 		saved_cursor.col = (colnr_T)(s - newline);
dcaee6
! 	}
dcaee6
  	retval = TRUE;
dcaee6
      }
dcaee6
      else
dcaee6
***************
dcaee6
*** 1581,1589 ****
dcaee6
  
dcaee6
  #if defined(FEAT_COMMENTS) || defined(PROTO)
dcaee6
  /*
dcaee6
!  * get_leader_len() returns the length of the prefix of the given string
dcaee6
!  * which introduces a comment.	If this string is not a comment then 0 is
dcaee6
!  * returned.
dcaee6
   * When "flags" is not NULL, it is set to point to the flags of the recognized
dcaee6
   * comment leader.
dcaee6
   * "backward" must be true for the "O" command.
dcaee6
--- 1589,1597 ----
dcaee6
  
dcaee6
  #if defined(FEAT_COMMENTS) || defined(PROTO)
dcaee6
  /*
dcaee6
!  * get_leader_len() returns the length in bytes of the prefix of the given
dcaee6
!  * string which introduces a comment.  If this string is not a comment then
dcaee6
!  * 0 is returned.
dcaee6
   * When "flags" is not NULL, it is set to point to the flags of the recognized
dcaee6
   * comment leader.
dcaee6
   * "backward" must be true for the "O" command.
dcaee6
*** ../vim-7.4.051/src/ops.c	2013-09-25 23:24:54.000000000 +0200
dcaee6
--- src/ops.c	2013-10-06 17:11:51.000000000 +0200
dcaee6
***************
dcaee6
*** 4989,4995 ****
dcaee6
  
dcaee6
  	    /*
dcaee6
  	     * When still in same paragraph, join the lines together.  But
dcaee6
! 	     * first delete the comment leader from the second line.
dcaee6
  	     */
dcaee6
  	    if (!is_end_par)
dcaee6
  	    {
dcaee6
--- 4989,4995 ----
dcaee6
  
dcaee6
  	    /*
dcaee6
  	     * When still in same paragraph, join the lines together.  But
dcaee6
! 	     * first delete the leader from the second line.
dcaee6
  	     */
dcaee6
  	    if (!is_end_par)
dcaee6
  	    {
dcaee6
***************
dcaee6
*** 4999,5009 ****
dcaee6
  		if (line_count < 0 && u_save_cursor() == FAIL)
dcaee6
  		    break;
dcaee6
  #ifdef FEAT_COMMENTS
dcaee6
- 		(void)del_bytes((long)next_leader_len, FALSE, FALSE);
dcaee6
  		if (next_leader_len > 0)
dcaee6
  		    mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L,
dcaee6
  						      (long)-next_leader_len);
dcaee6
  #endif
dcaee6
  		curwin->w_cursor.lnum--;
dcaee6
  		if (do_join(2, TRUE, FALSE, FALSE) == FAIL)
dcaee6
  		{
dcaee6
--- 4999,5023 ----
dcaee6
  		if (line_count < 0 && u_save_cursor() == FAIL)
dcaee6
  		    break;
dcaee6
  #ifdef FEAT_COMMENTS
dcaee6
  		if (next_leader_len > 0)
dcaee6
+ 		{
dcaee6
+ 		    (void)del_bytes((long)next_leader_len, FALSE, FALSE);
dcaee6
  		    mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L,
dcaee6
  						      (long)-next_leader_len);
dcaee6
+ 		} else
dcaee6
  #endif
dcaee6
+ 		    if (second_indent > 0)  /* the "leader" for FO_Q_SECOND */
dcaee6
+ 		{
dcaee6
+ 		    char_u *p = ml_get_curline();
dcaee6
+ 		    int indent = skipwhite(p) - p;
dcaee6
+ 
dcaee6
+ 		    if (indent > 0)
dcaee6
+ 		    {
dcaee6
+ 			(void)del_bytes(indent, FALSE, FALSE);
dcaee6
+ 			mark_col_adjust(curwin->w_cursor.lnum,
dcaee6
+ 					       (colnr_T)0, 0L, (long)-indent);
dcaee6
+ 		      }
dcaee6
+ 		}
dcaee6
  		curwin->w_cursor.lnum--;
dcaee6
  		if (do_join(2, TRUE, FALSE, FALSE) == FAIL)
dcaee6
  		{
dcaee6
*** ../vim-7.4.051/src/testdir/test68.in	2012-07-25 15:57:06.000000000 +0200
dcaee6
--- src/testdir/test68.in	2013-10-06 16:20:33.000000000 +0200
dcaee6
***************
dcaee6
*** 62,67 ****
dcaee6
--- 62,81 ----
dcaee6
  }
dcaee6
  
dcaee6
  STARTTEST
dcaee6
+ /^{/+3
dcaee6
+ :set tw=5 fo=t2a si
dcaee6
+ i  ?A_?
dcaee6
+ ENDTEST
dcaee6
+ 
dcaee6
+ {
dcaee6
+ 
dcaee6
+   x a
dcaee6
+   b
dcaee6
+  c
dcaee6
+ 
dcaee6
+ }
dcaee6
+ 
dcaee6
+ STARTTEST
dcaee6
  /^{/+1
dcaee6
  :set tw=5 fo=qn comments=:#
dcaee6
  gwap
dcaee6
*** ../vim-7.4.051/src/testdir/test68.ok	2012-07-25 16:03:05.000000000 +0200
dcaee6
--- src/testdir/test68.ok	2013-10-06 16:20:33.000000000 +0200
dcaee6
***************
dcaee6
*** 43,48 ****
dcaee6
--- 43,57 ----
dcaee6
  
dcaee6
  
dcaee6
  {
dcaee6
+ 
dcaee6
+   x a
dcaee6
+     b_
dcaee6
+     c
dcaee6
+ 
dcaee6
+ }
dcaee6
+ 
dcaee6
+ 
dcaee6
+ {
dcaee6
  # 1 a
dcaee6
  #   b
dcaee6
  }
dcaee6
*** ../vim-7.4.051/src/version.c	2013-10-06 15:46:06.000000000 +0200
dcaee6
--- src/version.c	2013-10-06 17:25:27.000000000 +0200
dcaee6
***************
dcaee6
*** 740,741 ****
dcaee6
--- 740,743 ----
dcaee6
  {   /* Add new patch number below this line */
dcaee6
+ /**/
dcaee6
+     52,
dcaee6
  /**/
dcaee6
dcaee6
-- 
dcaee6
ARTHUR:    Will you ask your master if he wants to join my court at Camelot?!
dcaee6
GUARD #1:  But then of course African swallows are not migratory.
dcaee6
GUARD #2:  Oh, yeah...
dcaee6
GUARD #1:  So they couldn't bring a coconut back anyway...
dcaee6
                                  The Quest for the Holy Grail (Monty Python)
dcaee6
dcaee6
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
dcaee6
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
dcaee6
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
dcaee6
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///