diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-07-14 16:49:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-14 16:49:03 +0800 |
commit | f0eb855607f82026d8a32dffb3cdf59212694538 (patch) | |
tree | b4532a00a60eefe2aee77e7bdbf7ef1eb769c9da /test | |
parent | 49ba36becd0bbf1052802b846f418aee673b28a5 (diff) | |
parent | c8401515cdaad20220e30f5a0c39ddb7bae77f5e (diff) | |
download | rneovim-f0eb855607f82026d8a32dffb3cdf59212694538.tar.gz rneovim-f0eb855607f82026d8a32dffb3cdf59212694538.tar.bz2 rneovim-f0eb855607f82026d8a32dffb3cdf59212694538.zip |
Merge pull request #29696 from zeertzjq/vim-9.1.0573
vim-patch:9.1.{0573,0574,0582}
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/legacy/ex_mode_spec.lua | 18 | ||||
-rw-r--r-- | test/old/testdir/setup.vim | 19 | ||||
-rw-r--r-- | test/old/testdir/test_ex_mode.vim | 31 |
3 files changed, 60 insertions, 8 deletions
diff --git a/test/functional/legacy/ex_mode_spec.lua b/test/functional/legacy/ex_mode_spec.lua index 574c3e4069..e033898d7a 100644 --- a/test/functional/legacy/ex_mode_spec.lua +++ b/test/functional/legacy/ex_mode_spec.lua @@ -48,7 +48,7 @@ describe('Ex mode', function() command('set noincsearch nohlsearch inccommand=') local screen = Screen.new(60, 6) screen:attach() - command([[call setline(1, ['foo foo', 'foo foo', 'foo foo'])]]) + command([[call setline(1, repeat(['foo foo'], 4))]]) command([[set number]]) feed('gQ') screen:expect([[ @@ -110,12 +110,24 @@ describe('Ex mode', function() :^ | ]]) + -- The printed line should overwrite the colon + feed('<CR>') + screen:expect([[ + {8: 2 }foo foo | + ^^^q | + {8: 2 }foo foo | + {8: 3 }foo foo | + {8: 4 }foo foo | + :^ | + ]]) + feed(':vi<CR>') screen:expect([[ {8: 1 }foo bar | {8: 2 }foo foo | - {8: 3 }^foo foo | - {1:~ }|*2 + {8: 3 }foo foo | + {8: 4 }^foo foo | + {1:~ }| | ]]) end) diff --git a/test/old/testdir/setup.vim b/test/old/testdir/setup.vim index 2e4085ce03..6f400c5e32 100644 --- a/test/old/testdir/setup.vim +++ b/test/old/testdir/setup.vim @@ -32,8 +32,8 @@ if exists('s:did_load') endif if g:testname !~ 'test_mapping.vim$' " Make "Q" switch to Ex mode. - " This does not work for all tests. - nnoremap Q gQ + " This does not work for all tests as Nvim only supports Vim Ex mode. + nnoremap Q gQ<Cmd>call<SID>ExStart()<CR> endif endif @@ -45,6 +45,21 @@ if exists('s:did_load') endif let s:did_load = 1 +func s:ExStart() + call feedkeys($"\<Cmd>call{expand('<SID>')}ExMayEnd()\<CR>") +endfunc + +func s:ExMayEnd() + " When :normal runs out of characters in Vim, the behavior is different in + " normal Ex mode vs. Vim Ex mode. + " - In normal Ex mode, "\n" is used. + " - In Vim Ex mode, Ctrl-C is used. + " Nvim only supports Vim Ex mode, so emulate the normal Ex mode behavior. + if state('m') == '' && mode(1) == 'cv' && getcharstr(1) == "\<C-C>" + call feedkeys("\n") + endif +endfunc + " Clear Nvim default user commands, mappings and menus. comclear mapclear diff --git a/test/old/testdir/test_ex_mode.vim b/test/old/testdir/test_ex_mode.vim index 42f08868a0..f55ba87a3e 100644 --- a/test/old/testdir/test_ex_mode.vim +++ b/test/old/testdir/test_ex_mode.vim @@ -69,7 +69,7 @@ func Test_Ex_substitute() CheckRunVimInTerminal let buf = RunVimInTerminal('', {'rows': 6}) - call term_sendkeys(buf, ":call setline(1, ['foo foo', 'foo foo', 'foo foo'])\<CR>") + call term_sendkeys(buf, ":call setline(1, repeat(['foo foo'], 4))\<CR>") call term_sendkeys(buf, ":set number\<CR>") call term_sendkeys(buf, "gQ") call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000) @@ -91,8 +91,14 @@ func Test_Ex_substitute() " Pressing enter in ex mode should print the current line call term_sendkeys(buf, "\<CR>") - call WaitForAssert({-> assert_match(' 3 foo foo', - \ term_getline(buf, 5))}, 1000) + call WaitForAssert({-> assert_match(' 3 foo foo', term_getline(buf, 5))}, 1000) + call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000) + + " The printed line should overwrite the colon + call term_sendkeys(buf, "\<CR>") + call WaitForAssert({-> assert_match(' 3 foo foo', term_getline(buf, 4))}, 1000) + call WaitForAssert({-> assert_match(' 4 foo foo', term_getline(buf, 5))}, 1000) + call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000) call term_sendkeys(buf, ":vi\<CR>") call WaitForAssert({-> assert_match('foo bar', term_getline(buf, 1))}, 1000) @@ -282,4 +288,23 @@ func Test_ex_mode_large_indent() endfunc +" Testing implicit print command +func Test_implicit_print() + new + call setline(1, ['one', 'two', 'three']) + call feedkeys('Q:let a=execute(":1,2")', 'xt') + call feedkeys('Q:let b=execute(":3")', 'xt') + call assert_equal('one two', a->split('\n')->join(' ')) + call assert_equal('three', b->split('\n')->join(' ')) + bw! +endfunc + +" Test inserting text after the trailing bar +func Test_insert_after_trailing_bar() + new + call feedkeys("Qi|\nfoo\n.\na|bar\nbar\n.\nc|baz\n.", "xt") + call assert_equal(['', 'foo', 'bar', 'baz'], getline(1, '$')) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab |