diff options
Diffstat (limited to 'test/functional/legacy/mapping_spec.lua')
-rw-r--r-- | test/functional/legacy/mapping_spec.lua | 83 |
1 files changed, 76 insertions, 7 deletions
diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua index 9eddec40f7..3fc324f66a 100644 --- a/test/functional/legacy/mapping_spec.lua +++ b/test/functional/legacy/mapping_spec.lua @@ -1,9 +1,13 @@ -- Test for mappings and abbreviations -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local expect, poke_eventloop = helpers.expect, helpers.poke_eventloop -local command, eq, eval, api = helpers.command, helpers.eq, helpers.eval, helpers.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() +local Screen = require('test.functional.ui.screen') + +local clear, feed, insert = n.clear, n.feed, n.insert +local expect, poke_eventloop = n.expect, n.poke_eventloop +local command, eq, eval, api = n.command, t.eq, n.eval, n.api +local exec = n.exec local sleep = vim.uv.sleep describe('mapping', function() @@ -23,6 +27,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 +46,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 +89,7 @@ describe('mapping', function() +]]) end) + -- oldtest: Test_map_feedkeys() it('feedkeys', function() insert([[ a b c d @@ -100,6 +107,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 +136,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 +150,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 +175,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 +192,62 @@ 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('a') + screen:expect([[ + ^ | + {1:~ }|*4 + | + ]]) + end + + feed('\23') + screen:expect([[ + ^ | + {1:~ }|*4 + ^W | + ]]) + feed('a') + screen:expect([[ + ^ | + {1:~ }|*4 + | + ]]) + + feed('<C-W>') + screen:expect([[ + ^ | + {1:~ }|*4 + ^W | + ]]) + feed('a') + screen:expect([[ + ^ | + {1:~ }|*4 + | + ]]) + end) end) |