Yukihiro Nakadaira wrote:

> There are two problems in block insert mode (<C-V> + I).
> 
> 1. When CTRL-C is used in block insert mode, text is inserted to first
>    line only even if multi-line was selected.
> 
> For example, when there are three lines and type "1G<C-V>jjIxxx<C-C>"
> 1: aaa        1: xxxaaa
> 2: bbb   ->   2: bbb
> 3: ccc        3: ccc
> 
> Please see op_insert() function in ops.c.  After invoking edit(),
> got_int is TRUE when CTRL-C was used.  Then u_save() returns FAIL and
> block_insert() is not invoked.  Thus text is not inserted to other line.

I think that is how it's supposed to happen: You abort the insertion
with CTRL-C, thus further changes are not done.

> 2. When CTRL-C is used in block insert mode, extra undo is added.
>    This happens when using GUI.
> 
> For example, type "<C-V>Ixxx<C-C>" and do undo:
>         insert        undo        undo
>   1:      ->  1: xxx   -> 1: xxx   ->  1:
> 
> In CUI:
>         insert        undo
>   1:      ->  1: xxx   -> 1:
> 
> This is stacktrace explaining how extra undo is added.

That is indeed a problem.  I think gotchars() should not be invoked for
peekc().  This patch should fix it, but we need to check for side
effects:

*** ../../vim-7.0.110/src/getchar.c     Tue Sep  5 12:57:14 2006
--- getchar.c   Tue Sep 26 17:44:45 2006
***************
*** 1960,1969 ****
                        c = Ctrl_C;
                    flush_buffers(TRUE);        /* flush all typeahead */
  
!                   /* Also record this character, it might be needed to
!                    * get out of Insert mode. */
!                   *typebuf.tb_buf = c;
!                   gotchars(typebuf.tb_buf, 1);
                    cmd_silent = FALSE;
  
                    break;
--- 1962,1974 ----
                        c = Ctrl_C;
                    flush_buffers(TRUE);        /* flush all typeahead */
  
!                   if (advance)
!                   {
!                       /* Also record this character, it might be needed to
!                        * get out of Insert mode. */
!                       *typebuf.tb_buf = c;
!                       gotchars(typebuf.tb_buf, 1);
!                   }
                    cmd_silent = FALSE;
  
                    break;

-- 
I am always surprised in the Linux world how quickly solutions can be
obtained.  (Imagine sending an email to Bill Gates, asking why Windows
crashed, and how to fix it...  and then getting an answer that fixed the
problem... <0>_<0> !)                         -- Mark Langdon

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- 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    ///

Reply via email to