home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.2.302 < prev    next >
Encoding:
Internet Message Format  |  2004-02-29  |  8.1 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.302
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.2.302
  11. Problem:    Using "CTRL-O ." in Insert mode doesn't work properly. (Benji
  12.         Fisher)
  13. Solution:   Restore "restart_edit" after an insert command that was not typed.
  14.         Avoid waiting with displaying the mode when there is no text to be
  15.         overwritten.
  16.         Fix that "CTRL-O ." sometimes doesn't put the cursor back after
  17.         the end-of-line.  Only reset the flag that CTRL-O was used past
  18.         the end of the line when restarting editing.  Update "o_lnum"
  19.         number when inserting text and "o_eol" is set.
  20. Files:        src/edit.c, src/normal.c
  21.  
  22.  
  23. *** ../vim-6.2.301/src/edit.c    Sun Feb 29 20:46:43 2004
  24. --- src/edit.c    Mon Mar  1 14:47:55 2004
  25. ***************
  26. *** 422,431 ****
  27.           }
  28.   #endif
  29.       }
  30.       }
  31.       else
  32.       arrow_used = FALSE;
  33. -     o_eol = FALSE;
  34.   
  35.       /* we are in insert mode now, don't need to start it anymore */
  36.       need_start_insertmode = FALSE;
  37. --- 422,431 ----
  38.           }
  39.   #endif
  40.       }
  41. +     o_eol = FALSE;
  42.       }
  43.       else
  44.       arrow_used = FALSE;
  45.   
  46.       /* we are in insert mode now, don't need to start it anymore */
  47.       need_start_insertmode = FALSE;
  48. ***************
  49. *** 779,785 ****
  50.           restart_edit = 'R';
  51.           else
  52.           restart_edit = 'I';
  53. -         o_lnum = curwin->w_cursor.lnum;
  54.   #ifdef FEAT_VIRTUALEDIT
  55.           if (virtual_active())
  56.           o_eol = FALSE;        /* cursor always keeps its column */
  57. --- 779,784 ----
  58. ***************
  59. *** 849,854 ****
  60. --- 848,858 ----
  61.           /*
  62.            * This is the ONLY return from edit()!
  63.            */
  64. +         /* Always update o_lnum, so that a "CTRL-O ." that adds a line
  65. +          * still puts the cursor back after the inserted text. */
  66. +         if (o_eol && gchar_cursor() == NUL)
  67. +         o_lnum = curwin->w_cursor.lnum;
  68.           if (ins_esc(&count, cmdchar))
  69.           return (c == Ctrl_O);
  70.           continue;
  71. *** ../vim-6.2.301/src/normal.c    Sun Feb 29 21:06:13 2004
  72. --- src/normal.c    Mon Mar  1 16:50:17 2004
  73. ***************
  74. *** 153,158 ****
  75. --- 153,159 ----
  76.   static void    nv_normal __ARGS((cmdarg_T *cap));
  77.   static void    nv_esc __ARGS((cmdarg_T *oap));
  78.   static void    nv_edit __ARGS((cmdarg_T *cap));
  79. + static void    invoke_edit __ARGS((cmdarg_T *cap, int repl, int cmd, int startln));
  80.   #ifdef FEAT_TEXTOBJ
  81.   static void    nv_object __ARGS((cmdarg_T *cap));
  82.   #endif
  83. ***************
  84. *** 1149,1155 ****
  85.               )
  86.               && (clear_cmdline
  87.               || redraw_cmdline)
  88. !             && msg_didany
  89.               && !msg_nowait
  90.               && KeyTyped)
  91.           || (restart_edit != 0
  92. --- 1150,1156 ----
  93.               )
  94.               && (clear_cmdline
  95.               || redraw_cmdline)
  96. !             && (msg_didout || (msg_didany && msg_scroll))
  97.               && !msg_nowait
  98.               && KeyTyped)
  99.           || (restart_edit != 0
  100. ***************
  101. *** 6114,6124 ****
  102.   #endif
  103.       stuffcharReadbuff('\r');
  104.       stuffcharReadbuff(ESC);
  105. !     /*
  106. !      * Give 'r' to edit(), to get the redo command right.
  107. !      */
  108. !     if (edit('r', FALSE, cap->count1))
  109. !         cap->retval |= CA_COMMAND_BUSY;
  110.       }
  111.       else
  112.       {
  113. --- 6115,6123 ----
  114.   #endif
  115.       stuffcharReadbuff('\r');
  116.       stuffcharReadbuff(ESC);
  117. !     /* Give 'r' to edit(), to get the redo command right. */
  118. !     invoke_edit(cap, TRUE, 'r', FALSE);
  119.       }
  120.       else
  121.       {
  122. ***************
  123. *** 6282,6292 ****
  124.           if (virtual_active())
  125.           coladvance(getviscol());
  126.   #endif
  127. !         /* This is a new edit command, not a restart.  We don't edit
  128. !          * recursively. */
  129. !         restart_edit = 0;
  130. !         if (edit(cap->arg ? 'V' : 'R', FALSE, cap->count1))
  131. !         cap->retval |= CA_COMMAND_BUSY;
  132.       }
  133.       }
  134.   }
  135. --- 6281,6287 ----
  136.           if (virtual_active())
  137.           coladvance(getviscol());
  138.   #endif
  139. !         invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE);
  140.       }
  141.       }
  142.   }
  143. ***************
  144. *** 6299,6306 ****
  145.   nv_vreplace(cap)
  146.       cmdarg_T    *cap;
  147.   {
  148. -     int        restart_edit_save;
  149.   # ifdef FEAT_VISUAL
  150.       if (VIsual_active)
  151.       {
  152. --- 6294,6299 ----
  153. ***************
  154. *** 6324,6337 ****
  155.           if (virtual_active())
  156.           coladvance(getviscol());
  157.   # endif
  158. !         /* This is a new edit command, not a restart.  Do allow using
  159. !          * CTRL-O rx from Insert mode. */
  160. !         restart_edit_save = restart_edit;
  161. !         restart_edit = 0;
  162. !         if (edit('v', FALSE, cap->count1))
  163. !         cap->retval |= CA_COMMAND_BUSY;
  164. !         if (restart_edit == 0)
  165. !         restart_edit = restart_edit_save;
  166.       }
  167.       }
  168.   }
  169. --- 6317,6323 ----
  170.           if (virtual_active())
  171.           coladvance(getviscol());
  172.   # endif
  173. !         invoke_edit(cap, TRUE, 'v', FALSE);
  174.       }
  175.       }
  176.   }
  177. ***************
  178. *** 7205,7217 ****
  179.       case 'I':
  180.       beginline(0);
  181.       if (!checkclearopq(oap))
  182. !     {
  183. !         /* This is a new edit command, not a restart.  We don't edit
  184. !          * recursively. */
  185. !         restart_edit = 0;
  186. !         if (edit('g', FALSE, cap->count1))
  187. !         cap->retval |= CA_COMMAND_BUSY;
  188. !     }
  189.       break;
  190.   
  191.   #ifdef FEAT_SEARCHPATH
  192. --- 7198,7204 ----
  193.       case 'I':
  194.       beginline(0);
  195.       if (!checkclearopq(oap))
  196. !         invoke_edit(cap, FALSE, 'g', FALSE);
  197.       break;
  198.   
  199.   #ifdef FEAT_SEARCHPATH
  200. ***************
  201. *** 7394,7404 ****
  202.   #endif
  203.               0, 0))
  204.       {
  205. !         /* This is a new edit command, not a restart.  We don't edit
  206. !          * recursively. */
  207. !         restart_edit = 0;
  208. !         if (edit(cap->cmdchar, TRUE, cap->count1))
  209. !         cap->retval |= CA_COMMAND_BUSY;
  210.       }
  211.       }
  212.   }
  213. --- 7381,7387 ----
  214.   #endif
  215.               0, 0))
  216.       {
  217. !         invoke_edit(cap, FALSE, cap->cmdchar, TRUE);
  218.       }
  219.       }
  220.   }
  221. ***************
  222. *** 7413,7421 ****
  223.       if (!checkclearopq(cap->oap))
  224.       {
  225.       /*
  226. !      * if restart_edit is TRUE, the last but one command is repeated
  227.        * instead of the last command (inserting text). This is used for
  228. !      * CTRL-O <.> in insert mode
  229.        */
  230.       if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL)
  231.           clearopbeep(cap->oap);
  232. --- 7396,7404 ----
  233.       if (!checkclearopq(cap->oap))
  234.       {
  235.       /*
  236. !      * If "restart_edit" is TRUE, the last but one command is repeated
  237.        * instead of the last command (inserting text). This is used for
  238. !      * CTRL-O <.> in insert mode.
  239.        */
  240.       if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL)
  241.           clearopbeep(cap->oap);
  242. ***************
  243. *** 7979,7990 ****
  244.       }
  245.   #endif
  246.   
  247. !     /* This is a new edit command, not a restart.  We don't edit
  248. !      * recursively. */
  249. !     restart_edit = 0;
  250. !     if (edit(cap->cmdchar, FALSE, cap->count1))
  251. !         cap->retval |= CA_COMMAND_BUSY;
  252.       }
  253.   }
  254.   
  255.   #ifdef FEAT_TEXTOBJ
  256. --- 7962,7999 ----
  257.       }
  258.   #endif
  259.   
  260. !     invoke_edit(cap, FALSE, cap->cmdchar, FALSE);
  261.       }
  262. + }
  263. + /*
  264. +  * Invoke edit() and take care of "restart_edit" and the return value.
  265. +  */
  266. +     static void
  267. + invoke_edit(cap, repl, cmd, startln)
  268. +     cmdarg_T    *cap;
  269. +     int        repl;        /* "r" or "gr" command */
  270. +     int        cmd;
  271. +     int        startln;
  272. + {
  273. +     int        restart_edit_save = 0;
  274. +     /* Complicated: When the user types "a<C-O>a" we don't want to do Insert
  275. +      * mode recursively.  But when doing "a<C-O>." or "a<C-O>rx" we do allow
  276. +      * it. */
  277. +     if (repl || !stuff_empty())
  278. +     restart_edit_save = restart_edit;
  279. +     else
  280. +     restart_edit_save = 0;
  281. +     /* Always reset "restart_edit", this is not a restarted edit. */
  282. +     restart_edit = 0;
  283. +     if (edit(cmd, startln, cap->count1))
  284. +     cap->retval |= CA_COMMAND_BUSY;
  285. +     if (restart_edit == 0)
  286. +     restart_edit = restart_edit_save;
  287.   }
  288.   
  289.   #ifdef FEAT_TEXTOBJ
  290. *** ../vim-6.2.301/src/version.c    Mon Mar  1 16:43:34 2004
  291. --- src/version.c    Mon Mar  1 16:46:22 2004
  292. ***************
  293. *** 639,640 ****
  294. --- 639,642 ----
  295.   {   /* Add new patch number below this line */
  296. + /**/
  297. +     302,
  298.   /**/
  299.  
  300. -- 
  301. MORTICIAN:    Bring out your dead!
  302.               [clang]
  303.               Bring out your dead!
  304.               [clang]
  305.               Bring out your dead!
  306. CUSTOMER:     Here's one -- nine pence.
  307. DEAD PERSON:  I'm not dead!
  308.                                   The Quest for the Holy Grail (Monty Python)
  309.  
  310.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  311. ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  312. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  313.  \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
  314.