diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/functional/legacy/mapping_spec.lua | 76 | ||||
| -rw-r--r-- | test/old/testdir/test_mapping.vim | 45 |
2 files changed, 116 insertions, 5 deletions
diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua index 272a79fa29..1078daec64 100644 --- a/test/functional/legacy/mapping_spec.lua +++ b/test/functional/legacy/mapping_spec.lua @@ -1,9 +1,11 @@ -- Test for mappings and abbreviations local t = require('test.functional.testutil')() +local Screen = require('test.functional.ui.screen') local clear, feed, insert = t.clear, t.feed, t.insert local expect, poke_eventloop = t.expect, t.poke_eventloop local command, eq, eval, api = t.command, t.eq, t.eval, t.api +local exec = t.exec local sleep = vim.uv.sleep describe('mapping', function() @@ -23,6 +25,7 @@ describe('mapping', function() vim ]]) end) + -- oldtest: Test_map_ctrl_c_insert() it('Ctrl-c works in Insert mode', function() -- Mapping of ctrl-c in insert mode command('set cpo-=< cpo-=k') @@ -41,6 +44,7 @@ describe('mapping', function() ]]) end) + -- oldtest: Test_map_ctrl_c_visual() it('Ctrl-c works in Visual mode', function() command([[vnoremap <c-c> :<C-u>$put ='vmap works'<cr>]]) feed('GV') @@ -83,6 +87,7 @@ describe('mapping', function() +]]) end) + -- oldtest: Test_map_feedkeys() it('feedkeys', function() insert([[ a b c d @@ -100,6 +105,7 @@ describe('mapping', function() ]]) end) + -- oldtest: Test_map_cursor() it('i_CTRL-G_U', function() -- <c-g>U<cursor> works only within a single line command('imapclear') @@ -128,7 +134,8 @@ describe('mapping', function() ]]) end) - it('dragging starts Select mode even if coming from mapping vim-patch:8.2.4806', function() + -- oldtest: Test_mouse_drag_mapped_start_select() + it('dragging starts Select mode even if coming from mapping', function() command('set mouse=a') command('set selectmode=mouse') @@ -141,7 +148,8 @@ describe('mapping', function() eq('s', eval('mode()')) end) - it('<LeftDrag> mapping in Insert mode works correctly vim-patch:8.2.4692', function() + -- oldtest: Test_mouse_drag_insert_map() + it('<LeftDrag> mapping in Insert mode works correctly', function() command('set mouse=a') command('inoremap <LeftDrag> <LeftDrag><Cmd>let g:dragged = 1<CR>') @@ -165,7 +173,8 @@ describe('mapping', function() eq('n', eval('mode()')) end) - it('timeout works after an <Nop> mapping is triggered on timeout vim-patch:8.1.0052', function() + -- oldtest: Test_map_after_timed_out_nop() + it('timeout works after an <Nop> mapping is triggered on timeout', function() command('set timeout timeoutlen=400') command('inoremap ab TEST') command('inoremap a <Nop>') @@ -181,4 +190,65 @@ describe('mapping', function() feed('b') expect('TEST') end) + + -- oldtest: Test_showcmd_part_map() + it("'showcmd' with a partial mapping", function() + local screen = Screen.new(60, 6) + screen:attach() + exec([[ + set notimeout showcmd + nnoremap ,a <Ignore> + nnoremap ;a <Ignore> + nnoremap Àa <Ignore> + nnoremap Ëa <Ignore> + nnoremap βa <Ignore> + nnoremap ωa <Ignore> + nnoremap …a <Ignore> + nnoremap <C-W>a <Ignore> + ]]) + + for _, c in ipairs({ ',', ';', 'À', 'Ë', 'β', 'ω', '…' }) do + feed(c) + screen:expect(([[ + ^ | + {1:~ }|*4 + %s | + ]]):format(c)) + feed('<C-C>') + command('echo') + screen:expect([[ + ^ | + {1:~ }|*4 + | + ]]) + end + + feed('\23') + screen:expect([[ + ^ | + {1:~ }|*4 + ^W | + ]]) + feed('<C-C>') + command('echo') + screen:expect([[ + ^ | + {1:~ }|*4 + | + ]]) + + feed('<C-W>') + screen:expect([[ + ^ | + {1:~ }|*4 + ^W | + ]]) + feed('<C-C>') + command('echo') + screen:expect([[ + ^ | + {1:~ }|*4 + | + ]]) + end) end) diff --git a/test/old/testdir/test_mapping.vim b/test/old/testdir/test_mapping.vim index 623228b347..811a260238 100644 --- a/test/old/testdir/test_mapping.vim +++ b/test/old/testdir/test_mapping.vim @@ -1693,7 +1693,7 @@ func Test_map_after_timed_out_nop() inoremap ab TEST inoremap a <Nop> END - call writefile(lines, 'Xtest_map_after_timed_out_nop') + call writefile(lines, 'Xtest_map_after_timed_out_nop', 'D') let buf = RunVimInTerminal('-S Xtest_map_after_timed_out_nop', #{rows: 6}) " Enter Insert mode @@ -1710,7 +1710,48 @@ func Test_map_after_timed_out_nop() " clean up call StopVimInTerminal(buf) - call delete('Xtest_map_after_timed_out_nop') +endfunc + +" Test 'showcmd' behavior with a partial mapping +func Test_showcmd_part_map() + CheckRunVimInTerminal + + let lines =<< trim eval END + set notimeout showcmd + nnoremap ,a <Ignore> + nnoremap ;a <Ignore> + nnoremap Àa <Ignore> + nnoremap Ëa <Ignore> + nnoremap βa <Ignore> + nnoremap ωa <Ignore> + nnoremap …a <Ignore> + nnoremap <C-W>a <Ignore> + END + call writefile(lines, 'Xtest_showcmd_part_map', 'D') + let buf = RunVimInTerminal('-S Xtest_showcmd_part_map', #{rows: 6}) + + call term_sendkeys(buf, ":set noruler | echo\<CR>") + call WaitForAssert({-> assert_equal('', term_getline(buf, 6))}) + + for c in [',', ';', 'À', 'Ë', 'β', 'ω', '…'] + call term_sendkeys(buf, c) + call WaitForAssert({-> assert_equal(c, trim(term_getline(buf, 6)))}) + call term_sendkeys(buf, "\<C-C>:echo\<CR>") + call WaitForAssert({-> assert_equal('', term_getline(buf, 6))}) + endfor + + call term_sendkeys(buf, "\<C-W>") + call WaitForAssert({-> assert_equal('^W', trim(term_getline(buf, 6)))}) + call term_sendkeys(buf, "\<C-C>:echo\<CR>") + call WaitForAssert({-> assert_equal('', term_getline(buf, 6))}) + + " Use feedkeys() as terminal buffer cannot forward this + call term_sendkeys(buf, ':call feedkeys("\<*C-W>", "m")' .. " | echo\<CR>") + call WaitForAssert({-> assert_equal('^W', trim(term_getline(buf, 6)))}) + call term_sendkeys(buf, "\<C-C>:echo\<CR>") + call WaitForAssert({-> assert_equal('', term_getline(buf, 6))}) + + call StopVimInTerminal(buf) endfunc func Test_using_past_typeahead() |