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