From f6a6db3e248dd6360dbd55574321ddc216848c13 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 17 Feb 2023 07:59:22 +0800 Subject: vim-patch:8.2.0148: mapping related function in wrong source file Problem: Mapping related function in wrong source file. Solution: Move the function. Add a few more test cases. (Yegappan Lakshmanan, closes vim/vim#5528) https://github.com/vim/vim/commit/7f51bbe0d19f1f0cb0321326f45a17b4f5155f89 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/setup.vim | 8 +++++--- src/nvim/testdir/test_mapping.vim | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim index f895287469..25ac2d1239 100644 --- a/src/nvim/testdir/setup.vim +++ b/src/nvim/testdir/setup.vim @@ -26,9 +26,11 @@ if exists('s:did_load') set viewoptions& set viewoptions+=options set switchbuf= - " Make "Q" switch to Ex mode. - " This does not work for all tests. - nnoremap Q gQ + if g:testname !~ 'test_mapping.vim$' + " Make "Q" switch to Ex mode. + " This does not work for all tests. + nnoremap Q gQ + endif endif " Common preparations for running tests. diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 5c5a65d4ca..6cf19306ec 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -934,6 +934,39 @@ func Test_abbr_remove() call assert_equal({}, maparg('foo', 'i', 1, 1)) endfunc +" Trigger an abbreviation using a special key +func Test_abbr_trigger_special() + new + iabbr teh the + call feedkeys("iteh\\", 'xt') + call assert_equal('the', getline(1)) + iunab teh + close! +endfunc + +" Test for '<' in 'cpoptions' +func Test_map_cpo_special_keycode() + set cpo-=< + imap xk Test + let d = maparg('xk', 'i', 0, 1) + call assert_equal(['x\k', 'Test', 'i'], [d.lhs, d.rhs, d.mode]) + call feedkeys(":imap x\\\"\", 'tx') + call assert_equal('"imap x\k', @:) + iunmap xk + " Nvim: no "<" flag in 'cpoptions'. + " set cpo+=< + " imap xk Test + " let d = maparg('xk', 'i', 0, 1) + " call assert_equal(['xk', 'Test', 'i'], [d.lhs, d.rhs, d.mode]) + " call feedkeys(":imap x\\\"\", 'tx') + " call assert_equal('"imap xk', @:) + " iunmap xk + set cpo-=< + " Modifying 'cpo' above adds some default mappings, remove them + mapclear + mapclear! +endfunc + func Test_map_cmdkey_redo() func SelectDash() call search('^---\n\zs', 'bcW') -- cgit