Skip to content

Commit abc7c7f

Browse files
committed
patch 8.1.1189: mode is not cleared when leaving Insert mode
Problem: Mode is not cleared when leaving Insert mode. Solution: Clear the mode when got_int is set. (Ozaki Kiichi, closes #4270)
1 parent d2e716e commit abc7c7f

4 files changed

Lines changed: 37 additions & 2 deletions

File tree

src/edit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4564,7 +4564,7 @@ ins_esc(
45644564
*/
45654565
if (reg_recording != 0 || restart_edit != NUL)
45664566
showmode();
4567-
else if (p_smd && !skip_showmode())
4567+
else if (p_smd && (got_int || !skip_showmode()))
45684568
msg("");
45694569

45704570
return TRUE; /* exit Insert mode */

src/testdir/test_bufline.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func Test_setbufline_getbufline()
1818
let b = bufnr('%')
1919
wincmd w
2020
call assert_equal(1, setbufline(b, 5, ['x']))
21-
call assert_equal(1, setbufline(1234, 1, ['x']))
21+
call assert_equal(1, setbufline(bufnr('$') + 1, 1, ['x']))
2222
call assert_equal(0, setbufline(b, 4, ['d', 'e']))
2323
call assert_equal(['c'], getbufline(b, 3))
2424
call assert_equal(['d'], getbufline(b, 4))

src/testdir/test_messages.vim

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
" Tests for :messages, :echomsg, :echoerr
22

3+
source shared.vim
4+
35
function Test_messages()
46
let oldmore = &more
57
try
@@ -92,3 +94,34 @@ func Test_echoerr()
9294
call assert_match("function('<lambda>\\d*')", execute(':echoerr {-> 1234}'))
9395
call test_ignore_error('RESET')
9496
endfunc
97+
98+
func Test_mode_message_at_leaving_insert_by_ctrl_c()
99+
if !has('terminal') || has('gui_running')
100+
return
101+
endif
102+
103+
" Set custom statusline built by user-defined function.
104+
let testfile = 'Xtest.vim'
105+
call writefile([
106+
\ 'func StatusLine() abort',
107+
\ ' return ""',
108+
\ 'endfunc',
109+
\ 'set statusline=%!StatusLine()',
110+
\ 'set laststatus=2',
111+
\ ], testfile)
112+
113+
let rows = 10
114+
let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows})
115+
call term_wait(buf, 200)
116+
call assert_equal('run', job_status(term_getjob(buf)))
117+
118+
call term_sendkeys(buf, "i")
119+
call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))})
120+
call term_sendkeys(buf, "\<C-C>")
121+
call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))})
122+
123+
call term_sendkeys(buf, ":qall!\<CR>")
124+
call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
125+
exe buf . 'bwipe!'
126+
call delete(testfile)
127+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1189,
774776
/**/
775777
1188,
776778
/**/

0 commit comments

Comments
 (0)