diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-01-18 07:23:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-18 07:23:48 +0800 |
commit | 8a07ca6c4baf9a72476df4b1851aa33165b4f9c5 (patch) | |
tree | 1b4578d206ed6328dee89efc75b9a00be940713b /test | |
parent | 780dd88b68b7a4d97c8b7ec6a8d33ab523ab04dd (diff) | |
download | rneovim-8a07ca6c4baf9a72476df4b1851aa33165b4f9c5.tar.gz rneovim-8a07ca6c4baf9a72476df4b1851aa33165b4f9c5.tar.bz2 rneovim-8a07ca6c4baf9a72476df4b1851aa33165b4f9c5.zip |
vim-patch:9.1.0040: issue with prompt buffer and hidden buffer (#27071)
Problem: Modifying a hidden buffer still interferes with prompt buffer
mode changes.
Solution: Save and restore b_prompt_insert.
(zeertzjq)
closes: vim/vim#13875
Modifying hidden buffer still interferes with prompt buffer mode changes
https://github.com/vim/vim/commit/f267847017976ab85117bdf75b45e769836f8d69
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/legacy/prompt_buffer_spec.lua | 18 | ||||
-rw-r--r-- | test/old/testdir/test_prompt_buffer.vim | 27 |
2 files changed, 35 insertions, 10 deletions
diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 59a9283868..e4810feedb 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -219,7 +219,7 @@ describe('prompt buffer', function() eq({ mode = 'i', blocking = false }, api.nvim_get_mode()) end) - -- oldtest: Test_prompt_close_modify_hidden() + -- oldtest: Test_prompt_leave_modify_hidden() it('modifying hidden buffer does not prevent prompt buffer mode change', function() source([[ file hidden @@ -228,14 +228,26 @@ describe('prompt buffer', function() new prompt set buftype=prompt + inoremap <buffer> w <Cmd>wincmd w<CR> inoremap <buffer> q <Cmd>bwipe!<CR> - autocmd BufWinLeave prompt call setbufline('hidden', 1, 'Test') + autocmd BufLeave prompt call appendbufline('hidden', '$', 'Leave') + autocmd BufEnter prompt call appendbufline('hidden', '$', 'Enter') + autocmd BufWinLeave prompt call appendbufline('hidden', '$', 'Close') ]]) feed('a') eq({ mode = 'i', blocking = false }, api.nvim_get_mode()) + feed('w') + eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) + feed('<C-W>w') + eq({ mode = 'i', blocking = false }, api.nvim_get_mode()) feed('q') eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) command('bwipe!') - expect('Test') + expect([[ + + Leave + Enter + Leave + Close]]) end) end) diff --git a/test/old/testdir/test_prompt_buffer.vim b/test/old/testdir/test_prompt_buffer.vim index 20daa07a3d..41e14ae427 100644 --- a/test/old/testdir/test_prompt_buffer.vim +++ b/test/old/testdir/test_prompt_buffer.vim @@ -298,9 +298,10 @@ func Test_prompt_appending_while_hidden() call StopVimInTerminal(buf) endfunc -" Modifying a hidden buffer while closing a prompt buffer should not prevent -" stopping of Insert mode. -func Test_prompt_close_modify_hidden() +" Modifying a hidden buffer while leaving a prompt buffer should not prevent +" stopping of Insert mode, and returning to the prompt buffer later should +" restore Insert mode. +func Test_prompt_leave_modify_hidden() call CanTestPromptBuffer() let script =<< trim END @@ -310,22 +311,34 @@ func Test_prompt_close_modify_hidden() new prompt set buftype=prompt + inoremap <buffer> w <Cmd>wincmd w<CR> inoremap <buffer> q <Cmd>bwipe!<CR> - autocmd BufWinLeave prompt call setbufline('hidden', 1, 'Test') + autocmd BufLeave prompt call appendbufline('hidden', '$', 'Leave') + autocmd BufEnter prompt call appendbufline('hidden', '$', 'Enter') + autocmd BufWinLeave prompt call appendbufline('hidden', '$', 'Close') END - call writefile(script, 'XpromptCloseModifyHidden', 'D') + call writefile(script, 'XpromptLeaveModifyHidden', 'D') - let buf = RunVimInTerminal('-S XpromptCloseModifyHidden', {'rows': 10}) + let buf = RunVimInTerminal('-S XpromptLeaveModifyHidden', {'rows': 10}) call TermWait(buf) call term_sendkeys(buf, "a") call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 10))}) + call term_sendkeys(buf, "w") + call WaitForAssert({-> assert_notmatch('-- INSERT --', term_getline(buf, 10))}) + + call term_sendkeys(buf, "\<C-W>w") + call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 10))}) + call term_sendkeys(buf, "q") call WaitForAssert({-> assert_notmatch('-- INSERT --', term_getline(buf, 10))}) call term_sendkeys(buf, ":bwipe!\<CR>") - call WaitForAssert({-> assert_equal('Test', term_getline(buf, 1))}) + call WaitForAssert({-> assert_equal('Leave', term_getline(buf, 2))}) + call WaitForAssert({-> assert_equal('Enter', term_getline(buf, 3))}) + call WaitForAssert({-> assert_equal('Leave', term_getline(buf, 4))}) + call WaitForAssert({-> assert_equal('Close', term_getline(buf, 5))}) call StopVimInTerminal(buf) endfunc |