Karsten Hopp 41c58d
To: vim_dev@googlegroups.com
Karsten Hopp 41c58d
Subject: Patch 7.3.792
Karsten Hopp 41c58d
Fcc: outbox
Karsten Hopp 41c58d
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 41c58d
Mime-Version: 1.0
Karsten Hopp 41c58d
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 41c58d
Content-Transfer-Encoding: 8bit
Karsten Hopp 41c58d
------------
Karsten Hopp 41c58d
Karsten Hopp 41c58d
Patch 7.3.792
Karsten Hopp 41c58d
Problem:    ":substitute" works differently without confirmation.
Karsten Hopp 41c58d
Solution:   Do not change the text when asking for confirmation, only display
Karsten Hopp 41c58d
	    it.
Karsten Hopp 41c58d
Files:	    src/ex_cmds.c
Karsten Hopp 41c58d
Karsten Hopp 41c58d
Karsten Hopp 41c58d
*** ../vim-7.3.791/src/ex_cmds.c	2013-01-17 18:33:58.000000000 +0100
Karsten Hopp 41c58d
--- src/ex_cmds.c	2013-01-30 16:01:58.000000000 +0100
Karsten Hopp 41c58d
***************
Karsten Hopp 41c58d
*** 4727,4732 ****
Karsten Hopp 41c58d
--- 4727,4734 ----
Karsten Hopp 41c58d
  			}
Karsten Hopp 41c58d
  			else
Karsten Hopp 41c58d
  			{
Karsten Hopp 41c58d
+ 			    char_u *orig_line = NULL;
Karsten Hopp 41c58d
+ 			    int    len_change = 0;
Karsten Hopp 41c58d
  #ifdef FEAT_FOLDING
Karsten Hopp 41c58d
  			    int save_p_fen = curwin->w_p_fen;
Karsten Hopp 41c58d
  
Karsten Hopp 41c58d
***************
Karsten Hopp 41c58d
*** 4737,4745 ****
Karsten Hopp 41c58d
  			    temp = RedrawingDisabled;
Karsten Hopp 41c58d
  			    RedrawingDisabled = 0;
Karsten Hopp 41c58d
  
Karsten Hopp 41c58d
  			    search_match_lines = regmatch.endpos[0].lnum
Karsten Hopp 41c58d
  						  - regmatch.startpos[0].lnum;
Karsten Hopp 41c58d
! 			    search_match_endcol = regmatch.endpos[0].col;
Karsten Hopp 41c58d
  			    highlight_match = TRUE;
Karsten Hopp 41c58d
  
Karsten Hopp 41c58d
  			    update_topline();
Karsten Hopp 41c58d
--- 4739,4781 ----
Karsten Hopp 41c58d
  			    temp = RedrawingDisabled;
Karsten Hopp 41c58d
  			    RedrawingDisabled = 0;
Karsten Hopp 41c58d
  
Karsten Hopp 41c58d
+ 			    if (new_start != NULL)
Karsten Hopp 41c58d
+ 			    {
Karsten Hopp 41c58d
+ 				/* There already was a substitution, we would
Karsten Hopp 41c58d
+ 				 * like to show this to the user.  We cannot
Karsten Hopp 41c58d
+ 				 * really update the line, it would change
Karsten Hopp 41c58d
+ 				 * what matches.  Temporarily replace the line
Karsten Hopp 41c58d
+ 				 * and change it back afterwards. */
Karsten Hopp 41c58d
+ 				orig_line = vim_strsave(ml_get(lnum));
Karsten Hopp 41c58d
+ 				if (orig_line != NULL)
Karsten Hopp 41c58d
+ 				{
Karsten Hopp 41c58d
+ 				    char_u *new_line = concat_str(new_start,
Karsten Hopp 41c58d
+ 						     sub_firstline + copycol);
Karsten Hopp 41c58d
+ 
Karsten Hopp 41c58d
+ 				    if (new_line == NULL)
Karsten Hopp 41c58d
+ 				    {
Karsten Hopp 41c58d
+ 					vim_free(orig_line);
Karsten Hopp 41c58d
+ 					orig_line = NULL;
Karsten Hopp 41c58d
+ 				    }
Karsten Hopp 41c58d
+ 				    else
Karsten Hopp 41c58d
+ 				    {
Karsten Hopp 41c58d
+ 					/* Position the cursor relative to the
Karsten Hopp 41c58d
+ 					 * end of the line, the previous
Karsten Hopp 41c58d
+ 					 * substitute may have inserted or
Karsten Hopp 41c58d
+ 					 * deleted characters before the
Karsten Hopp 41c58d
+ 					 * cursor. */
Karsten Hopp 41c58d
+ 					len_change = STRLEN(new_line)
Karsten Hopp 41c58d
+ 							  - STRLEN(orig_line);
Karsten Hopp 41c58d
+ 					curwin->w_cursor.col += len_change;
Karsten Hopp 41c58d
+ 					ml_replace(lnum, new_line, FALSE);
Karsten Hopp 41c58d
+ 				    }
Karsten Hopp 41c58d
+ 				}
Karsten Hopp 41c58d
+ 			    }
Karsten Hopp 41c58d
+ 
Karsten Hopp 41c58d
  			    search_match_lines = regmatch.endpos[0].lnum
Karsten Hopp 41c58d
  						  - regmatch.startpos[0].lnum;
Karsten Hopp 41c58d
! 			    search_match_endcol = regmatch.endpos[0].col
Karsten Hopp 41c58d
! 								 + len_change;
Karsten Hopp 41c58d
  			    highlight_match = TRUE;
Karsten Hopp 41c58d
  
Karsten Hopp 41c58d
  			    update_topline();
Karsten Hopp 41c58d
***************
Karsten Hopp 41c58d
*** 4781,4786 ****
Karsten Hopp 41c58d
--- 4817,4826 ----
Karsten Hopp 41c58d
  			    msg_didout = FALSE;	/* don't scroll up */
Karsten Hopp 41c58d
  			    msg_col = 0;
Karsten Hopp 41c58d
  			    gotocmdline(TRUE);
Karsten Hopp 41c58d
+ 
Karsten Hopp 41c58d
+ 			    /* restore the line */
Karsten Hopp 41c58d
+ 			    if (orig_line != NULL)
Karsten Hopp 41c58d
+ 				ml_replace(lnum, orig_line, FALSE);
Karsten Hopp 41c58d
  			}
Karsten Hopp 41c58d
  
Karsten Hopp 41c58d
  			need_wait_return = FALSE; /* no hit-return prompt */
Karsten Hopp 41c58d
***************
Karsten Hopp 41c58d
*** 5045,5058 ****
Karsten Hopp 41c58d
  		 * The check for nmatch_tl is needed for when multi-line
Karsten Hopp 41c58d
  		 * matching must replace the lines before trying to do another
Karsten Hopp 41c58d
  		 * match, otherwise "\@<=" won't work.
Karsten Hopp 41c58d
- 		 * When asking the user we like to show the already replaced
Karsten Hopp 41c58d
- 		 * text, but don't do it when "\<@=" or "\<@!" is used, it
Karsten Hopp 41c58d
- 		 * changes what matches.
Karsten Hopp 41c58d
  		 * When the match starts below where we start searching also
Karsten Hopp 41c58d
  		 * need to replace the line first (using \zs after \n).
Karsten Hopp 41c58d
  		 */
Karsten Hopp 41c58d
  		if (lastone
Karsten Hopp 41c58d
- 			|| (do_ask && !re_lookbehind(regmatch.regprog))
Karsten Hopp 41c58d
  			|| nmatch_tl > 0
Karsten Hopp 41c58d
  			|| (nmatch = vim_regexec_multi(&regmatch, curwin,
Karsten Hopp 41c58d
  							curbuf, sub_firstlnum,
Karsten Hopp 41c58d
--- 5085,5094 ----
Karsten Hopp 41c58d
*** ../vim-7.3.791/src/version.c	2013-01-30 14:55:35.000000000 +0100
Karsten Hopp 41c58d
--- src/version.c	2013-01-30 16:25:36.000000000 +0100
Karsten Hopp 41c58d
***************
Karsten Hopp 41c58d
*** 727,728 ****
Karsten Hopp 41c58d
--- 727,730 ----
Karsten Hopp 41c58d
  {   /* Add new patch number below this line */
Karsten Hopp 41c58d
+ /**/
Karsten Hopp 41c58d
+     792,
Karsten Hopp 41c58d
  /**/
Karsten Hopp 41c58d
Karsten Hopp 41c58d
-- 
Karsten Hopp 41c58d
Trees moving back and forth is what makes the wind blow.
Karsten Hopp 41c58d
Karsten Hopp 41c58d
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 41c58d
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 41c58d
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 41c58d
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///