From abc7c7fc5a098374f5543a237e6c9dd918848b34 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 20 Apr 2019 15:10:13 +0200 Subject: [PATCH] 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) --- src/edit.c | 2 +- src/testdir/test_bufline.vim | 2 +- src/testdir/test_messages.vim | 33 +++++++++++++++++++++++++++++++++ src/version.c | 2 ++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/edit.c b/src/edit.c index d378cd16f..43c8a8b63 100644 --- a/src/edit.c +++ b/src/edit.c @@ -4564,7 +4564,7 @@ ins_esc( */ if (reg_recording != 0 || restart_edit != NUL) showmode(); - else if (p_smd && !skip_showmode()) + else if (p_smd && (got_int || !skip_showmode())) msg(""); return TRUE; /* exit Insert mode */ diff --git a/src/testdir/test_bufline.vim b/src/testdir/test_bufline.vim index 524144d5b..d2d692922 100644 --- a/src/testdir/test_bufline.vim +++ b/src/testdir/test_bufline.vim @@ -18,7 +18,7 @@ func Test_setbufline_getbufline() let b = bufnr('%') wincmd w call assert_equal(1, setbufline(b, 5, ['x'])) - call assert_equal(1, setbufline(1234, 1, ['x'])) + call assert_equal(1, setbufline(bufnr('$') + 1, 1, ['x'])) call assert_equal(0, setbufline(b, 4, ['d', 'e'])) call assert_equal(['c'], getbufline(b, 3)) call assert_equal(['d'], getbufline(b, 4)) diff --git a/src/testdir/test_messages.vim b/src/testdir/test_messages.vim index 4bdc1365e..2d1d6d9b9 100644 --- a/src/testdir/test_messages.vim +++ b/src/testdir/test_messages.vim @@ -1,5 +1,7 @@ " Tests for :messages, :echomsg, :echoerr +source shared.vim + function Test_messages() let oldmore = &more try @@ -92,3 +94,34 @@ func Test_echoerr() call assert_match("function('\\d*')", execute(':echoerr {-> 1234}')) call test_ignore_error('RESET') endfunc + +func Test_mode_message_at_leaving_insert_by_ctrl_c() + if !has('terminal') || has('gui_running') + return + endif + + " Set custom statusline built by user-defined function. + let testfile = 'Xtest.vim' + call writefile([ + \ 'func StatusLine() abort', + \ ' return ""', + \ 'endfunc', + \ 'set statusline=%!StatusLine()', + \ 'set laststatus=2', + \ ], testfile) + + let rows = 10 + let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows}) + call term_wait(buf, 200) + call assert_equal('run', job_status(term_getjob(buf))) + + call term_sendkeys(buf, "i") + call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))}) + call term_sendkeys(buf, "\") + call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))}) + + call term_sendkeys(buf, ":qall!\") + call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))}) + exe buf . 'bwipe!' + call delete(testfile) +endfunc diff --git a/src/version.c b/src/version.c index 27614587f..4e88823a5 100644 --- a/src/version.c +++ b/src/version.c @@ -771,6 +771,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1189, /**/ 1188, /**/ -- 2.40.0