diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-07-30 07:35:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-30 07:35:25 +0800 |
commit | 4b852bc555121f888a284dde45a56a0b7a42b851 (patch) | |
tree | ef2853df0c60b432398ba802a497ee1470ff34ec /test/old | |
parent | d131c48c823c30f519506eddcaef662dad5afa43 (diff) | |
download | rneovim-4b852bc555121f888a284dde45a56a0b7a42b851.tar.gz rneovim-4b852bc555121f888a284dde45a56a0b7a42b851.tar.bz2 rneovim-4b852bc555121f888a284dde45a56a0b7a42b851.zip |
vim-patch:9.1.0642: Check that mapping rhs starts with lhs fails if not simplified (#29909)
Problem: Check that mapping rhs starts with lhs doesn't work if lhs is
not simplified.
Solution: Keep track of the mapblock containing the alternative lhs and
also compare with it (zeertzjq).
fixes: vim/vim#15376
closes: vim/vim#15384
https://github.com/vim/vim/commit/9d997addc7bd0fd132a809cf497ed816e61fcd25
Cherry-pick removal of save_m_str from patch 8.2.4059.
Diffstat (limited to 'test/old')
-rw-r--r-- | test/old/testdir/test_mapping.vim | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/old/testdir/test_mapping.vim b/test/old/testdir/test_mapping.vim index 2a4d068dea..4abe73ab3d 100644 --- a/test/old/testdir/test_mapping.vim +++ b/test/old/testdir/test_mapping.vim @@ -1672,6 +1672,49 @@ func Test_unmap_simplifiable() unmap <C-I> endfunc +" Test that the first byte of rhs is not remapped if rhs starts with lhs. +func Test_map_rhs_starts_with_lhs() + new + func MapExpr() + return "\<C-R>\<C-P>" + endfunc + + for expr in [v:false, v:true] + if expr + imap <buffer><expr> <C-R> MapExpr() + else + imap <buffer> <C-R> <C-R><C-P> + endif + + for restore in [v:false, v:true] + if restore + let saved = maparg('<C-R>', 'i', v:false, v:true) + iunmap <buffer> <C-R> + call mapset(saved) + endif + + let @a = 'foo' + call feedkeys("S\<C-R>a", 'tx') + call assert_equal('foo', getline('.')) + + let @a = 'bar' + call feedkeys("S\<*C-R>a", 'tx') + call assert_equal('bar', getline('.')) + endfor + endfor + + " When two mappings are used for <C-I> and <Tab>, remapping should work. + imap <buffer> <C-I> <Tab>bar + imap <buffer> <Tab> foo + call feedkeys("S\<Tab>", 'xt') + call assert_equal('foo', getline('.')) + call feedkeys("S\<*C-I>", 'xt') + call assert_equal('foobar', getline('.')) + + delfunc MapExpr + bwipe! +endfunc + func Test_expr_map_escape_special() nnoremap … <Cmd>let g:got_ellipsis += 1<CR> func Func() |