updated for version 7.4.569 v7.4.569
authorBram Moolenaar <Bram@vim.org>
Wed, 14 Jan 2015 11:44:41 +0000 (12:44 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 14 Jan 2015 11:44:41 +0000 (12:44 +0100)
Problem:    Having CTRL-C interrupt or not does not check the mode of the
            mapping. (Ingo Karkat)
Solution:   Use a bitmask with the map mode. (Christian Brabandt)

src/getchar.c
src/globals.h
src/structs.h
src/testdir/test_mapping.in
src/testdir/test_mapping.ok
src/ui.c
src/version.c

index 174cfa892fde49e9f375973cef72b03df44d68cf..3ae5f40609faf50ef5cb94a21922d7693f6ff5a8 100644 (file)
@@ -3708,8 +3708,13 @@ do_map(maptype, arg, mode, abbrev)
        if (!did_it)
            retval = 2;                     /* no match */
        else if (*keys == Ctrl_C)
+       {
            /* If CTRL-C has been unmapped, reuse it for Interrupting. */
-           mapped_ctrl_c = FALSE;
+           if (map_table == curbuf->b_maphash)
+               curbuf->b_mapped_ctrl_c &= ~mode;
+           else
+               mapped_ctrl_c &= ~mode;
+       }
        goto theend;
     }
 
@@ -3744,7 +3749,12 @@ do_map(maptype, arg, mode, abbrev)
 
     /* If CTRL-C has been mapped, don't always use it for Interrupting. */
     if (*keys == Ctrl_C)
-       mapped_ctrl_c = TRUE;
+    {
+       if (map_table == curbuf->b_maphash)
+           curbuf->b_mapped_ctrl_c |= mode;
+       else
+           mapped_ctrl_c |= mode;
+    }
 
     mp->m_keys = vim_strsave(keys);
     mp->m_str = vim_strsave(rhs);
index d1fdc33acc7086521ce1d9d93ffadf55e9cc3929..a26a8b535a1c2712bf8aa4edacfc62403f1c5985 100644 (file)
@@ -958,7 +958,7 @@ EXTERN char_u       *exe_name;              /* the name of the executable */
 #ifdef USE_ON_FLY_SCROLL
 EXTERN int     dont_scroll INIT(= FALSE);/* don't use scrollbars when TRUE */
 #endif
-EXTERN int     mapped_ctrl_c INIT(= FALSE); /* CTRL-C is mapped */
+EXTERN int     mapped_ctrl_c INIT(= FALSE); /* modes where CTRL-C is mapped */
 EXTERN int     ctrl_c_interrupts INIT(= TRUE); /* CTRL-C sets got_int */
 
 EXTERN cmdmod_T        cmdmod;                 /* Ex command modifiers */
index d24175320f21939fab060217189a7577c16e1cfa..7e60a387a2e55b95e2f1698f65dc3e74ff381384 100644 (file)
@@ -1802,6 +1802,7 @@ struct file_buffer
     cryptstate_T *b_cryptstate;        /* Encryption state while reading or writing
                                 * the file. NULL when not using encryption. */
 #endif
+    int                b_mapped_ctrl_c; /* modes where CTRL-C is mapped */
 
 }; /* file_buffer */
 
index 5f895a46f2179bfa547a7b0cab15499e316e0566..c957569f4d8835bf3d71ab12ae4cb3b257c2bb01 100644 (file)
@@ -8,6 +8,15 @@ STARTTEST
 :inoreab чкпр   vim
 GAчкпр 
 \e
+:" mapping of ctrl-c in insert mode
+:set cpo-=< cpo-=k
+:inoremap <c-c> <ctrl-c>
+:cnoremap <c-c> dummy
+:cunmap <c-c>
+GA
+TEST2: CTRL-C |\ 3A|
+\e
+:nunmap <c-c>
 
 : " langmap should not get remapped in insert mode
 :inoremap { FAIL_ilangmap
index 8d949765827ecff87fd87677e5cc39a19a6cebff..cd0e2e1ca11b9cf61bc39e3e184118edf97800f9 100644 (file)
@@ -1,4 +1,6 @@
 test starts here:
 vim
+TEST2: CTRL-C |<ctrl-c>A|
+
 +
 +
index b268cd78d4b1c5513963f8465618493b6aa165d5..6fc5bde21cc273d828ee1123517b603b8fd28065 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -180,7 +180,7 @@ ui_inchar(buf, maxlen, wtime, tb_change_cnt)
 
        /* ... there is no need for CTRL-C to interrupt something, don't let
         * it set got_int when it was mapped. */
-       if (mapped_ctrl_c)
+       if ((mapped_ctrl_c | curbuf->b_mapped_ctrl_c) & State)
            ctrl_c_interrupts = FALSE;
     }
 
index 4f9777ffa978a9c351b3d970f0b69108108b1d7c..a1b14941fd22fc4bca3e27e8ba4aed21eb334f63 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    569,
 /**/
     568,
 /**/