To: vim-dev@vim.org Subject: Patch 6.2.302 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.302 Problem: Using "CTRL-O ." in Insert mode doesn't work properly. (Benji Fisher) Solution: Restore "restart_edit" after an insert command that was not typed. Avoid waiting with displaying the mode when there is no text to be overwritten. Fix that "CTRL-O ." sometimes doesn't put the cursor back after the end-of-line. Only reset the flag that CTRL-O was used past the end of the line when restarting editing. Update "o_lnum" number when inserting text and "o_eol" is set. Files: src/edit.c, src/normal.c *** ../vim-6.2.301/src/edit.c Sun Feb 29 20:46:43 2004 --- src/edit.c Mon Mar 1 14:47:55 2004 *************** *** 422,431 **** } #endif } } else arrow_used = FALSE; - o_eol = FALSE; /* we are in insert mode now, don't need to start it anymore */ need_start_insertmode = FALSE; --- 422,431 ---- } #endif } + o_eol = FALSE; } else arrow_used = FALSE; /* we are in insert mode now, don't need to start it anymore */ need_start_insertmode = FALSE; *************** *** 779,785 **** restart_edit = 'R'; else restart_edit = 'I'; - o_lnum = curwin->w_cursor.lnum; #ifdef FEAT_VIRTUALEDIT if (virtual_active()) o_eol = FALSE; /* cursor always keeps its column */ --- 779,784 ---- *************** *** 849,854 **** --- 848,858 ---- /* * This is the ONLY return from edit()! */ + /* Always update o_lnum, so that a "CTRL-O ." that adds a line + * still puts the cursor back after the inserted text. */ + if (o_eol && gchar_cursor() == NUL) + o_lnum = curwin->w_cursor.lnum; + if (ins_esc(&count, cmdchar)) return (c == Ctrl_O); continue; *** ../vim-6.2.301/src/normal.c Sun Feb 29 21:06:13 2004 --- src/normal.c Mon Mar 1 16:50:17 2004 *************** *** 153,158 **** --- 153,159 ---- static void nv_normal __ARGS((cmdarg_T *cap)); static void nv_esc __ARGS((cmdarg_T *oap)); static void nv_edit __ARGS((cmdarg_T *cap)); + static void invoke_edit __ARGS((cmdarg_T *cap, int repl, int cmd, int startln)); #ifdef FEAT_TEXTOBJ static void nv_object __ARGS((cmdarg_T *cap)); #endif *************** *** 1149,1155 **** ) && (clear_cmdline || redraw_cmdline) ! && msg_didany && !msg_nowait && KeyTyped) || (restart_edit != 0 --- 1150,1156 ---- ) && (clear_cmdline || redraw_cmdline) ! && (msg_didout || (msg_didany && msg_scroll)) && !msg_nowait && KeyTyped) || (restart_edit != 0 *************** *** 6114,6124 **** #endif stuffcharReadbuff('\r'); stuffcharReadbuff(ESC); ! /* ! * Give 'r' to edit(), to get the redo command right. ! */ ! if (edit('r', FALSE, cap->count1)) ! cap->retval |= CA_COMMAND_BUSY; } else { --- 6115,6123 ---- #endif stuffcharReadbuff('\r'); stuffcharReadbuff(ESC); ! ! /* Give 'r' to edit(), to get the redo command right. */ ! invoke_edit(cap, TRUE, 'r', FALSE); } else { *************** *** 6282,6292 **** if (virtual_active()) coladvance(getviscol()); #endif ! /* This is a new edit command, not a restart. We don't edit ! * recursively. */ ! restart_edit = 0; ! if (edit(cap->arg ? 'V' : 'R', FALSE, cap->count1)) ! cap->retval |= CA_COMMAND_BUSY; } } } --- 6281,6287 ---- if (virtual_active()) coladvance(getviscol()); #endif ! invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE); } } } *************** *** 6299,6306 **** nv_vreplace(cap) cmdarg_T *cap; { - int restart_edit_save; - # ifdef FEAT_VISUAL if (VIsual_active) { --- 6294,6299 ---- *************** *** 6324,6337 **** if (virtual_active()) coladvance(getviscol()); # endif ! /* This is a new edit command, not a restart. Do allow using ! * CTRL-O rx from Insert mode. */ ! restart_edit_save = restart_edit; ! restart_edit = 0; ! if (edit('v', FALSE, cap->count1)) ! cap->retval |= CA_COMMAND_BUSY; ! if (restart_edit == 0) ! restart_edit = restart_edit_save; } } } --- 6317,6323 ---- if (virtual_active()) coladvance(getviscol()); # endif ! invoke_edit(cap, TRUE, 'v', FALSE); } } } *************** *** 7205,7217 **** case 'I': beginline(0); if (!checkclearopq(oap)) ! { ! /* This is a new edit command, not a restart. We don't edit ! * recursively. */ ! restart_edit = 0; ! if (edit('g', FALSE, cap->count1)) ! cap->retval |= CA_COMMAND_BUSY; ! } break; #ifdef FEAT_SEARCHPATH --- 7198,7204 ---- case 'I': beginline(0); if (!checkclearopq(oap)) ! invoke_edit(cap, FALSE, 'g', FALSE); break; #ifdef FEAT_SEARCHPATH *************** *** 7394,7404 **** #endif 0, 0)) { ! /* This is a new edit command, not a restart. We don't edit ! * recursively. */ ! restart_edit = 0; ! if (edit(cap->cmdchar, TRUE, cap->count1)) ! cap->retval |= CA_COMMAND_BUSY; } } } --- 7381,7387 ---- #endif 0, 0)) { ! invoke_edit(cap, FALSE, cap->cmdchar, TRUE); } } } *************** *** 7413,7421 **** if (!checkclearopq(cap->oap)) { /* ! * if restart_edit is TRUE, the last but one command is repeated * instead of the last command (inserting text). This is used for ! * CTRL-O <.> in insert mode */ if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL) clearopbeep(cap->oap); --- 7396,7404 ---- if (!checkclearopq(cap->oap)) { /* ! * If "restart_edit" is TRUE, the last but one command is repeated * instead of the last command (inserting text). This is used for ! * CTRL-O <.> in insert mode. */ if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL) clearopbeep(cap->oap); *************** *** 7979,7990 **** } #endif ! /* This is a new edit command, not a restart. We don't edit ! * recursively. */ ! restart_edit = 0; ! if (edit(cap->cmdchar, FALSE, cap->count1)) ! cap->retval |= CA_COMMAND_BUSY; } } #ifdef FEAT_TEXTOBJ --- 7962,7999 ---- } #endif ! invoke_edit(cap, FALSE, cap->cmdchar, FALSE); } + } + + /* + * Invoke edit() and take care of "restart_edit" and the return value. + */ + static void + invoke_edit(cap, repl, cmd, startln) + cmdarg_T *cap; + int repl; /* "r" or "gr" command */ + int cmd; + int startln; + { + int restart_edit_save = 0; + + /* Complicated: When the user types "aa" we don't want to do Insert + * mode recursively. But when doing "a." or "arx" we do allow + * it. */ + if (repl || !stuff_empty()) + restart_edit_save = restart_edit; + else + restart_edit_save = 0; + + /* Always reset "restart_edit", this is not a restarted edit. */ + restart_edit = 0; + + if (edit(cmd, startln, cap->count1)) + cap->retval |= CA_COMMAND_BUSY; + + if (restart_edit == 0) + restart_edit = restart_edit_save; } #ifdef FEAT_TEXTOBJ *** ../vim-6.2.301/src/version.c Mon Mar 1 16:43:34 2004 --- src/version.c Mon Mar 1 16:46:22 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 302, /**/ -- MORTICIAN: Bring out your dead! [clang] Bring out your dead! [clang] Bring out your dead! CUSTOMER: Here's one -- nine pence. DEAD PERSON: I'm not dead! The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///