424e24c
To: vim-dev@vim.org
424e24c
Subject: Patch 7.0.038
424e24c
Fcc: outbox
424e24c
From: Bram Moolenaar <Bram@moolenaar.net>
424e24c
Mime-Version: 1.0
424e24c
Content-Type: text/plain; charset=ISO-8859-1
424e24c
Content-Transfer-Encoding: 8bit
424e24c
------------
424e24c
424e24c
Patch 7.0.038
424e24c
Problem:    When calling complete() from an Insert mode expression mapping
424e24c
	    text could be inserted in an improper way.
424e24c
Solution:   Make undo_allowed() global and use it in complete().
424e24c
Files:	    src/undo.c, src/proto/undo.pro, src/eval.c
424e24c
424e24c
424e24c
*** ../vim-7.0.037/src/undo.c	Sat Apr 22 00:01:05 2006
424e24c
--- src/undo.c	Mon Jul  3 22:23:22 2006
424e24c
***************
424e24c
*** 84,90 ****
424e24c
  static void u_unch_branch __ARGS((u_header_T *uhp));
424e24c
  static u_entry_T *u_get_headentry __ARGS((void));
424e24c
  static void u_getbot __ARGS((void));
424e24c
- static int undo_allowed __ARGS((void));
424e24c
  static int u_savecommon __ARGS((linenr_T, linenr_T, linenr_T));
424e24c
  static void u_doit __ARGS((int count));
424e24c
  static void u_undoredo __ARGS((int undo));
424e24c
--- 84,89 ----
424e24c
***************
424e24c
*** 196,202 ****
424e24c
   * Return TRUE when undo is allowed.  Otherwise give an error message and
424e24c
   * return FALSE.
424e24c
   */
424e24c
!     static int
424e24c
  undo_allowed()
424e24c
  {
424e24c
      /* Don't allow changes when 'modifiable' is off.  */
424e24c
--- 195,201 ----
424e24c
   * Return TRUE when undo is allowed.  Otherwise give an error message and
424e24c
   * return FALSE.
424e24c
   */
424e24c
!     int
424e24c
  undo_allowed()
424e24c
  {
424e24c
      /* Don't allow changes when 'modifiable' is off.  */
424e24c
*** ../vim-7.0.037/src/proto/undo.pro	Mon Apr 10 16:38:50 2006
424e24c
--- src/proto/undo.pro	Mon Jul  3 22:25:07 2006
424e24c
***************
424e24c
*** 4,9 ****
424e24c
--- 4,10 ----
424e24c
  extern int u_savesub __ARGS((linenr_T lnum));
424e24c
  extern int u_inssub __ARGS((linenr_T lnum));
424e24c
  extern int u_savedel __ARGS((linenr_T lnum, long nlines));
424e24c
+ extern int undo_allowed __ARGS((void));
424e24c
  extern void u_undo __ARGS((int count));
424e24c
  extern void u_redo __ARGS((int count));
424e24c
  extern void undo_time __ARGS((long step, int sec, int absolute));
424e24c
*** ../vim-7.0.037/src/eval.c	Thu Jun 22 21:01:19 2006
424e24c
--- src/eval.c	Mon Jul 10 23:03:13 2006
424e24c
***************
424e24c
*** 8252,8257 ****
424e24c
--- 8252,8263 ----
424e24c
  	EMSG(_("E785: complete() can only be used in Insert mode"));
424e24c
  	return;
424e24c
      }
424e24c
+ 
424e24c
+     /* Check for undo allowed here, because if something was already inserted
424e24c
+      * the line was already saved for undo and this check isn't done. */
424e24c
+     if (!undo_allowed())
424e24c
+ 	return;
424e24c
+ 
424e24c
      if (argvars[1].v_type != VAR_LIST || argvars[1].vval.v_list == NULL)
424e24c
      {
424e24c
  	EMSG(_(e_invarg));
424e24c
*** ../vim-7.0.037/src/version.c	Tue Jul 11 22:59:04 2006
424e24c
--- src/version.c	Wed Jul 12 20:31:49 2006
424e24c
***************
424e24c
*** 668,669 ****
424e24c
--- 668,671 ----
424e24c
  {   /* Add new patch number below this line */
424e24c
+ /**/
424e24c
+     38,
424e24c
  /**/
424e24c
424e24c
-- 
424e24c
If someone questions your market projections, simply point out that your
424e24c
target market is "People who are nuts" and "People who will buy any damn
424e24c
thing".  Nobody is going to tell you there aren't enough of those people
424e24c
to go around.
424e24c
				(Scott Adams - The Dilbert principle)
424e24c
424e24c
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
424e24c
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
424e24c
\\\        download, build and distribute -- http://www.A-A-P.org        ///
424e24c
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///