From d52cc668c736ef6ca7ee3655a7eb7fe6475afadc Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 10 Apr 2023 07:33:26 +0800 Subject: vim-patch:9.0.1443: ending Insert mode when accessing a hidden prompt buffer (#22984) Problem: Ending Insert mode when accessing a hidden prompt buffer. Solution: Don't stop Insert mode when it was active before. (closes vim/vim#12237) https://github.com/vim/vim/commit/05a627c3d4e42a18f76c14828d68ee4747118211 Co-authored-by: Bram Moolenaar --- test/functional/legacy/prompt_buffer_spec.lua | 6 ++++++ test/old/testdir/test_prompt_buffer.vim | 11 +++++++++++ 2 files changed, 17 insertions(+) (limited to 'test') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 6c72cde855..5c3f8a6f8c 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -247,6 +247,7 @@ describe('prompt buffer', function() func DoAppend() call appendbufline('prompt', '$', 'Test') + return '' endfunc ]]) feed('asomething') @@ -254,7 +255,12 @@ describe('prompt buffer', function() neq(prev_win, meths.get_current_win()) feed('exit') eq(prev_win, meths.get_current_win()) + eq({ mode = 'n', blocking = false }, meths.get_mode()) command('call DoAppend()') eq({ mode = 'n', blocking = false }, meths.get_mode()) + feed('i') + eq({ mode = 'i', blocking = false }, meths.get_mode()) + command('call DoAppend()') + eq({ mode = 'i', blocking = false }, meths.get_mode()) end) end) diff --git a/test/old/testdir/test_prompt_buffer.vim b/test/old/testdir/test_prompt_buffer.vim index 43d8bb4789..2cc3f19b59 100644 --- a/test/old/testdir/test_prompt_buffer.vim +++ b/test/old/testdir/test_prompt_buffer.vim @@ -271,6 +271,7 @@ func Test_prompt_appending_while_hidden() func DoAppend() call appendbufline('prompt', '$', 'Test') + return '' endfunc END call writefile(script, 'XpromptBuffer', 'D') @@ -283,11 +284,21 @@ func Test_prompt_appending_while_hidden() call term_sendkeys(buf, "exit\") call TermWait(buf) + call assert_notmatch('-- INSERT --', term_getline(buf, 10)) call term_sendkeys(buf, ":call DoAppend()\") call TermWait(buf) call assert_notmatch('-- INSERT --', term_getline(buf, 10)) + call term_sendkeys(buf, "i") + call TermWait(buf) + call assert_match('-- INSERT --', term_getline(buf, 10)) + + call term_sendkeys(buf, "\=DoAppend()\") + call TermWait(buf) + call assert_match('-- INSERT --', term_getline(buf, 10)) + + call term_sendkeys(buf, "\") call StopVimInTerminal(buf) endfunc -- cgit