1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0504
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0504
Problem: When CTRL-C is mapped it triggers InsertLeave.
Solution: Make CTRL-C behave the same way when typed or used in a mapping.
Files: src/edit.c, src/testdir/test_edit.vim
*** ../vim-8.1.0503/src/edit.c 2018-09-30 21:43:17.179693404 +0200
--- src/edit.c 2018-11-02 11:58:53.235548305 +0100
***************
*** 1048,1054 ****
if (ins_esc(&count, cmdchar, nomove))
{
! if (cmdchar != 'r' && cmdchar != 'v')
ins_apply_autocmds(EVENT_INSERTLEAVE);
did_cursorhold = FALSE;
return (c == Ctrl_O);
--- 1048,1057 ----
if (ins_esc(&count, cmdchar, nomove))
{
! // When CTRL-C was typed got_int will be set, with the result
! // that the autocommands won't be executed. When mapped got_int
! // is not set, but let's keep the behavior the same.
! if (cmdchar != 'r' && cmdchar != 'v' && c != Ctrl_C)
ins_apply_autocmds(EVENT_INSERTLEAVE);
did_cursorhold = FALSE;
return (c == Ctrl_O);
***************
*** 2408,2414 ****
int
vim_is_ctrl_x_key(int c)
{
! /* Always allow ^R - let it's results then be checked */
if (c == Ctrl_R)
return TRUE;
--- 2411,2417 ----
int
vim_is_ctrl_x_key(int c)
{
! // Always allow ^R - let its results then be checked
if (c == Ctrl_R)
return TRUE;
*** ../vim-8.1.0503/src/testdir/test_edit.vim 2018-07-28 17:07:48.608154066 +0200
--- src/testdir/test_edit.vim 2018-11-02 11:50:34.466489066 +0100
***************
*** 1409,1411 ****
--- 1409,1441 ----
bwipe XAltFile
call delete('XAltFile')
endfunc
+
+ func Test_leave_insert_autocmd()
+ new
+ au InsertLeave * let g:did_au = 1
+ let g:did_au = 0
+ call feedkeys("afoo\<Esc>", 'tx')
+ call assert_equal(1, g:did_au)
+ call assert_equal('foo', getline(1))
+
+ let g:did_au = 0
+ call feedkeys("Sbar\<C-C>", 'tx')
+ call assert_equal(0, g:did_au)
+ call assert_equal('bar', getline(1))
+
+ inoremap x xx<Esc>
+ let g:did_au = 0
+ call feedkeys("Saax", 'tx')
+ call assert_equal(1, g:did_au)
+ call assert_equal('aaxx', getline(1))
+
+ inoremap x xx<C-C>
+ let g:did_au = 0
+ call feedkeys("Sbbx", 'tx')
+ call assert_equal(0, g:did_au)
+ call assert_equal('bbxx', getline(1))
+
+ bwipe!
+ au! InsertLeave
+ iunmap x
+ endfunc
*** ../vim-8.1.0503/src/version.c 2018-11-01 21:14:50.541818034 +0100
--- src/version.c 2018-11-02 11:51:43.970086497 +0100
***************
*** 794,795 ****
--- 794,797 ----
{ /* Add new patch number below this line */
+ /**/
+ 504,
/**/
--
ARTHUR: Who are you?
TALL KNIGHT: We are the Knights Who Say "Ni"!
BEDEVERE: No! Not the Knights Who Say "Ni"!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|