aboutsummaryrefslogtreecommitdiff
path: root/test/old/testdir/test_prompt_buffer.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-03 08:36:14 +0800
committerGitHub <noreply@github.com>2023-04-03 08:36:14 +0800
commit10baf89712724b4b95f7c641f2012f051737003c (patch)
treeeec22a0282d1c291ea54d3d0d4a7dd1feb2b91c9 /test/old/testdir/test_prompt_buffer.vim
parent53f36806f1b5107c0570ffbf57180a8e08f45b2e (diff)
downloadrneovim-10baf89712724b4b95f7c641f2012f051737003c.tar.gz
rneovim-10baf89712724b4b95f7c641f2012f051737003c.tar.bz2
rneovim-10baf89712724b4b95f7c641f2012f051737003c.zip
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) https://github.com/vim/vim/commit/cde8de034524d00aba4ff4142e658baff511e12d Cherry-pick test_prompt_buffer.vim changes from patch 9.0.0631. Co-authored-by: orbital <orbital@holgerines.de>
Diffstat (limited to 'test/old/testdir/test_prompt_buffer.vim')
-rw-r--r--test/old/testdir/test_prompt_buffer.vim41
1 files changed, 39 insertions, 2 deletions
diff --git a/test/old/testdir/test_prompt_buffer.vim b/test/old/testdir/test_prompt_buffer.vim
index b1288b4892..43d8bb4789 100644
--- a/test/old/testdir/test_prompt_buffer.vim
+++ b/test/old/testdir/test_prompt_buffer.vim
@@ -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