vim-patch:9.0.1439: start Insert mode when accessing a hidden prompt buffer (#22867)

Problem:    Start Insert mode when accessing a hidden prompt buffer.
Solution:   Call leaving_window() in aucmd_restbuf(). (Thorben Tröbst,
            closes vim/vim#12148, closes vim/vim#12147)

cde8de0345

Cherry-pick test_prompt_buffer.vim changes from patch 9.0.0631.

Co-authored-by: orbital <orbital@holgerines.de>
This commit is contained in:
zeertzjq
2023-04-03 08:36:14 +08:00
committed by GitHub
parent 53f36806f1
commit 10baf89712
4 changed files with 84 additions and 8 deletions

View File

@@ -238,7 +238,7 @@ func Test_prompt_while_writing_to_hidden_buffer()
\ done'], #{out_io: 'buffer', out_name: ''})
startinsert
END
eval script->writefile(scriptName)
eval script->writefile(scriptName, 'D')
let buf = RunVimInTerminal('-S ' .. scriptName, {})
call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))})
@@ -251,7 +251,44 @@ func Test_prompt_while_writing_to_hidden_buffer()
call WaitForAssert({-> assert_equal('cmd:testtesttest', term_getline(buf, 1))})
call StopVimInTerminal(buf)
call delete(scriptName)
endfunc
func Test_prompt_appending_while_hidden()
call CanTestPromptBuffer()
let script =<< trim END
new prompt
set buftype=prompt
set bufhidden=hide
func s:TextEntered(text)
if a:text == 'exit'
close
endif
echowin 'Entered:' a:text
endfunc
call prompt_setcallback(bufnr(), function('s:TextEntered'))
func DoAppend()
call appendbufline('prompt', '$', 'Test')
endfunc
END
call writefile(script, 'XpromptBuffer', 'D')
let buf = RunVimInTerminal('-S XpromptBuffer', {'rows': 10})
call TermWait(buf)
call term_sendkeys(buf, "asomething\<CR>")
call TermWait(buf)
call term_sendkeys(buf, "exit\<CR>")
call TermWait(buf)
call term_sendkeys(buf, ":call DoAppend()\<CR>")
call TermWait(buf)
call assert_notmatch('-- INSERT --', term_getline(buf, 10))
call StopVimInTerminal(buf)
endfunc
" vim: shiftwidth=2 sts=2 expandtab