diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2024-01-19 12:10:31 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-19 12:10:31 +0800 |
| commit | 0ef27180e31671a043b28547da327cd52f1a87c4 (patch) | |
| tree | c27d0a5ab971cc09c1b52400027654488016301f /test/functional | |
| parent | f58c6135084f75e6250fd6b11eac410fb9a21b7a (diff) | |
| parent | 26f836586479239935115944bff1dd2d156ef569 (diff) | |
Merge pull request #27088 from zeertzjq/backportrelease-0.9
Backport to release-0.9
Diffstat (limited to 'test/functional')
| -rw-r--r-- | test/functional/legacy/prompt_buffer_spec.lua | 33 | ||||
| -rw-r--r-- | test/functional/terminal/ex_terminal_spec.lua | 9 | ||||
| -rw-r--r-- | test/functional/ui/inccommand_spec.lua | 51 | ||||
| -rw-r--r-- | test/functional/ui/inccommand_user_spec.lua | 18 |
4 files changed, 111 insertions, 0 deletions
diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 5c3f8a6f8c..b18b9c8055 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -4,6 +4,7 @@ local feed = helpers.feed local source = helpers.source local clear = helpers.clear local command = helpers.command +local expect = helpers.expect local poke_eventloop = helpers.poke_eventloop local meths = helpers.meths local eq = helpers.eq @@ -263,4 +264,36 @@ describe('prompt buffer', function() command('call DoAppend()') eq({ mode = 'i', blocking = false }, meths.get_mode()) end) + + -- oldtest: Test_prompt_leave_modify_hidden() + it('modifying hidden buffer does not prevent prompt buffer mode change', function() + source([[ + file hidden + set bufhidden=hide + enew + new prompt + set buftype=prompt + + inoremap <buffer> w <Cmd>wincmd w<CR> + inoremap <buffer> q <Cmd>bwipe!<CR> + 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 }, meths.get_mode()) + feed('w') + eq({ mode = 'n', blocking = false }, meths.get_mode()) + feed('<C-W>w') + eq({ mode = 'i', blocking = false }, meths.get_mode()) + feed('q') + eq({ mode = 'n', blocking = false }, meths.get_mode()) + command('bwipe!') + expect([[ + + Leave + Enter + Leave + Close]]) + end) end) diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 427146b2e5..93945b0365 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -139,6 +139,15 @@ describe(':terminal', function() eq({ blocking=false, mode='t' }, nvim('get_mode')) eq({'InsertLeave', 'TermEnter'}, eval('g:events')) end) + + it('switching to terminal buffer immediately after :stopinsert #27031', function() + command('terminal') + command('vnew') + feed('i') + eq({ blocking = false, mode = 'i' }, nvim('get_mode')) + command('stopinsert | wincmd p') + eq({ blocking = false, mode = 'nt' }, nvim('get_mode')) + end) end) local function test_terminal_with_fake_shell(backslash) diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 26d759801b..848903cc80 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -3250,3 +3250,54 @@ it("with 'inccommand' typing :filter doesn't segfault or leak memory #19057", fu feed('i') assert_alive() end) + +it("'inccommand' value can be changed multiple times #27086", function() + clear() + local screen = Screen.new(30, 20) + common_setup(screen, 'split', 'foo1\nfoo2\nfoo3') + for _ = 1, 3 do + feed(':%s/foo/bar') + screen:expect([[ + {12:bar}1 | + {12:bar}2 | + {12:bar}3 | + {15:~ }|*7 + {11:[No Name] [+] }| + |1| {12:bar}1 | + |2| {12:bar}2 | + |3| {12:bar}3 | + {15:~ }|*4 + {10:[Preview] }| + :%s/foo/bar^ | + ]]) + feed('<Esc>') + command('set inccommand=nosplit') + feed(':%s/foo/bar') + screen:expect([[ + {12:bar}1 | + {12:bar}2 | + {12:bar}3 | + {15:~ }|*16 + :%s/foo/bar^ | + ]]) + feed('<Esc>') + command('set inccommand=split') + end +end) + +it("'inccommand' disables preview if preview buffer can't be created #27086", function() + clear() + meths.buf_set_name(0, '[Preview]') + local screen = Screen.new(30, 20) + common_setup(screen, 'split', 'foo1\nfoo2\nfoo3') + eq('split', meths.get_option_value('inccommand', {})) + feed(':%s/foo/bar') + screen:expect([[ + {12:bar}1 | + {12:bar}2 | + {12:bar}3 | + {15:~ }|*16 + :%s/foo/bar^ | + ]]) + eq('nosplit', meths.get_option_value('inccommand', {})) +end) diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index ef715ba832..f4394e36ce 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -1,6 +1,8 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') +local meths = helpers.meths local clear = helpers.clear +local eq = helpers.eq local exec_lua = helpers.exec_lua local insert = helpers.insert local feed = helpers.feed @@ -543,6 +545,22 @@ describe("'inccommand' for user commands", function() test_preview_break_undo() end) end) + + it('disables preview if preview buffer cannot be created #27086', function() + command('set inccommand=split') + meths.buf_set_name(0, '[Preview]') + exec_lua([[ + vim.api.nvim_create_user_command('Test', function() end, { + nargs = '*', + preview = function(_, _, _) + return 2 + end + }) + ]]) + eq('split', meths.get_option_value('inccommand', {})) + feed(':Test') + eq('nosplit', meths.get_option_value('inccommand', {})) + end) end) describe("'inccommand' with multiple buffers", function() |
