Karsten Hopp 833af2
To: vim_dev@googlegroups.com
Karsten Hopp 833af2
Subject: Patch 7.3.1303
Karsten Hopp 833af2
Fcc: outbox
Karsten Hopp 833af2
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 833af2
Mime-Version: 1.0
Karsten Hopp 833af2
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 833af2
Content-Transfer-Encoding: 8bit
Karsten Hopp 833af2
------------
Karsten Hopp 833af2
Karsten Hopp 833af2
Patch 7.3.1303 (after 7.3.1290)
Karsten Hopp 833af2
Problem:    Undo is synced whenever CTRL-R = is called, breaking some plugins.
Karsten Hopp 833af2
Solution:   Only break undo when calling setline() or append().
Karsten Hopp 833af2
Files:	    src/globals.h, src/eval.c, src/edit.c, src/testdir/test61.in,
Karsten Hopp 833af2
	    src/testdir/test61.ok
Karsten Hopp 833af2
Karsten Hopp 833af2
Karsten Hopp 833af2
*** ../vim-7.3.1302/src/globals.h	2013-04-24 14:06:42.000000000 +0200
Karsten Hopp 833af2
--- src/globals.h	2013-07-04 19:53:44.000000000 +0200
Karsten Hopp 833af2
***************
Karsten Hopp 833af2
*** 916,921 ****
Karsten Hopp 833af2
--- 916,925 ----
Karsten Hopp 833af2
  EXTERN int allow_keys INIT(= FALSE);	/* allow key codes when no_mapping
Karsten Hopp 833af2
  					 * is set */
Karsten Hopp 833af2
  EXTERN int no_u_sync INIT(= 0);		/* Don't call u_sync() */
Karsten Hopp 833af2
+ #ifdef FEAT_EVAL
Karsten Hopp 833af2
+ EXTERN int u_sync_once INIT(= 0);	/* Call u_sync() once when evaluating
Karsten Hopp 833af2
+ 					   an expression. */
Karsten Hopp 833af2
+ #endif
Karsten Hopp 833af2
  
Karsten Hopp 833af2
  EXTERN int restart_edit INIT(= 0);	/* call edit when next cmd finished */
Karsten Hopp 833af2
  EXTERN int arrow_used;			/* Normally FALSE, set to TRUE after
Karsten Hopp 833af2
*** ../vim-7.3.1302/src/eval.c	2013-06-29 13:58:26.000000000 +0200
Karsten Hopp 833af2
--- src/eval.c	2013-07-04 19:57:18.000000000 +0200
Karsten Hopp 833af2
***************
Karsten Hopp 833af2
*** 8742,8747 ****
Karsten Hopp 833af2
--- 8742,8755 ----
Karsten Hopp 833af2
      typval_T	*tv;
Karsten Hopp 833af2
      long	added = 0;
Karsten Hopp 833af2
  
Karsten Hopp 833af2
+     /* When coming here from Insert mode, sync undo, so that this can be
Karsten Hopp 833af2
+      * undone separately from what was previously inserted. */
Karsten Hopp 833af2
+     if (u_sync_once == 2)
Karsten Hopp 833af2
+     {
Karsten Hopp 833af2
+ 	u_sync_once = 1; /* notify that u_sync() was called */
Karsten Hopp 833af2
+ 	u_sync(TRUE);
Karsten Hopp 833af2
+     }
Karsten Hopp 833af2
+ 
Karsten Hopp 833af2
      lnum = get_tv_lnum(argvars);
Karsten Hopp 833af2
      if (lnum >= 0
Karsten Hopp 833af2
  	    && lnum <= curbuf->b_ml.ml_line_count
Karsten Hopp 833af2
***************
Karsten Hopp 833af2
*** 16408,16413 ****
Karsten Hopp 833af2
--- 16416,16430 ----
Karsten Hopp 833af2
  	rettv->vval.v_number = 1;	/* FAIL */
Karsten Hopp 833af2
  	if (line == NULL || lnum < 1 || lnum > curbuf->b_ml.ml_line_count + 1)
Karsten Hopp 833af2
  	    break;
Karsten Hopp 833af2
+ 
Karsten Hopp 833af2
+ 	/* When coming here from Insert mode, sync undo, so that this can be
Karsten Hopp 833af2
+ 	 * undone separately from what was previously inserted. */
Karsten Hopp 833af2
+ 	if (u_sync_once == 2)
Karsten Hopp 833af2
+ 	{
Karsten Hopp 833af2
+ 	    u_sync_once = 1; /* notify that u_sync() was called */
Karsten Hopp 833af2
+ 	    u_sync(TRUE);
Karsten Hopp 833af2
+ 	}
Karsten Hopp 833af2
+ 
Karsten Hopp 833af2
  	if (lnum <= curbuf->b_ml.ml_line_count)
Karsten Hopp 833af2
  	{
Karsten Hopp 833af2
  	    /* existing line, replace it */
Karsten Hopp 833af2
*** ../vim-7.3.1302/src/edit.c	2013-07-03 13:16:18.000000000 +0200
Karsten Hopp 833af2
--- src/edit.c	2013-07-04 20:22:25.000000000 +0200
Karsten Hopp 833af2
***************
Karsten Hopp 833af2
*** 8135,8143 ****
Karsten Hopp 833af2
  # ifdef USE_IM_CONTROL
Karsten Hopp 833af2
  	int	im_on = im_get_status();
Karsten Hopp 833af2
  # endif
Karsten Hopp 833af2
! 	/* Sync undo, so the effect of e.g., setline() can be undone. */
Karsten Hopp 833af2
! 	u_sync(TRUE);
Karsten Hopp 833af2
! 	ins_need_undo = TRUE;
Karsten Hopp 833af2
  
Karsten Hopp 833af2
  	regname = get_expr_register();
Karsten Hopp 833af2
  # ifdef USE_IM_CONTROL
Karsten Hopp 833af2
--- 8135,8143 ----
Karsten Hopp 833af2
  # ifdef USE_IM_CONTROL
Karsten Hopp 833af2
  	int	im_on = im_get_status();
Karsten Hopp 833af2
  # endif
Karsten Hopp 833af2
! 	/* Sync undo when evaluating the expression calls setline() or
Karsten Hopp 833af2
! 	 * append(), so that it can be undone separately. */
Karsten Hopp 833af2
! 	u_sync_once = 2;
Karsten Hopp 833af2
  
Karsten Hopp 833af2
  	regname = get_expr_register();
Karsten Hopp 833af2
  # ifdef USE_IM_CONTROL
Karsten Hopp 833af2
***************
Karsten Hopp 833af2
*** 8178,8183 ****
Karsten Hopp 833af2
--- 8178,8186 ----
Karsten Hopp 833af2
  #ifdef FEAT_EVAL
Karsten Hopp 833af2
      }
Karsten Hopp 833af2
      --no_u_sync;
Karsten Hopp 833af2
+     if (u_sync_once == 1)
Karsten Hopp 833af2
+ 	ins_need_undo = TRUE;
Karsten Hopp 833af2
+     u_sync_once = 0;
Karsten Hopp 833af2
  #endif
Karsten Hopp 833af2
  #ifdef FEAT_CMDL_INFO
Karsten Hopp 833af2
      clear_showcmd();
Karsten Hopp 833af2
*** ../vim-7.3.1302/src/testdir/test61.in	2013-06-26 21:56:33.000000000 +0200
Karsten Hopp 833af2
--- src/testdir/test61.in	2013-07-04 20:23:47.000000000 +0200
Karsten Hopp 833af2
***************
Karsten Hopp 833af2
*** 93,99 ****
Karsten Hopp 833af2
  :set ul=100
Karsten Hopp 833af2
  o1?a2?=setline('.','1234')
Karsten Hopp 833af2
  
Karsten Hopp 833af2
! ?uu:%w >>test.out
Karsten Hopp 833af2
  :qa!
Karsten Hopp 833af2
  ENDTEST
Karsten Hopp 833af2
  
Karsten Hopp 833af2
--- 93,109 ----
Karsten Hopp 833af2
  :set ul=100
Karsten Hopp 833af2
  o1?a2?=setline('.','1234')
Karsten Hopp 833af2
  
Karsten Hopp 833af2
! ?uu:"
Karsten Hopp 833af2
! oc?
Karsten Hopp 833af2
! :set ul=100
Karsten Hopp 833af2
! o1?a2?=setline('.','1234')
Karsten Hopp 833af2
! 
Karsten Hopp 833af2
! ?u:"
Karsten Hopp 833af2
! od?
Karsten Hopp 833af2
! :set ul=100
Karsten Hopp 833af2
! o1?a2?=string(123)
Karsten Hopp 833af2
! ?u:"
Karsten Hopp 833af2
! :%w >>test.out
Karsten Hopp 833af2
  :qa!
Karsten Hopp 833af2
  ENDTEST
Karsten Hopp 833af2
  
Karsten Hopp 833af2
*** ../vim-7.3.1302/src/testdir/test61.ok	2013-06-15 17:54:36.000000000 +0200
Karsten Hopp 833af2
--- src/testdir/test61.ok	2013-07-04 20:24:25.000000000 +0200
Karsten Hopp 833af2
***************
Karsten Hopp 833af2
*** 44,46 ****
Karsten Hopp 833af2
--- 44,49 ----
Karsten Hopp 833af2
  
Karsten Hopp 833af2
  a
Karsten Hopp 833af2
  b
Karsten Hopp 833af2
+ c
Karsten Hopp 833af2
+ 12
Karsten Hopp 833af2
+ d
Karsten Hopp 833af2
*** ../vim-7.3.1302/src/version.c	2013-07-03 22:28:32.000000000 +0200
Karsten Hopp 833af2
--- src/version.c	2013-07-04 20:09:30.000000000 +0200
Karsten Hopp 833af2
***************
Karsten Hopp 833af2
*** 730,731 ****
Karsten Hopp 833af2
--- 730,733 ----
Karsten Hopp 833af2
  {   /* Add new patch number below this line */
Karsten Hopp 833af2
+ /**/
Karsten Hopp 833af2
+     1303,
Karsten Hopp 833af2
  /**/
Karsten Hopp 833af2
Karsten Hopp 833af2
Karsten Hopp 833af2
-- 
Karsten Hopp 833af2
In Africa some of the native tribes have a custom of beating the ground
Karsten Hopp 833af2
with clubs and uttering spine chilling cries.  Anthropologists call
Karsten Hopp 833af2
this a form of primitive self-expression.  In America we call it golf.
Karsten Hopp 833af2
Karsten Hopp 833af2
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 833af2
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 833af2
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 833af2
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///