summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_mapping.vim
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:15 +0000
commit6e9cd6b491267e6dff3e3f3f37d8af5f28e40672 (patch)
tree35661af16c4a0ef2a9a8e225d2d5cc82605ea289 /src/testdir/test_mapping.vim
parentAdding upstream version 2:9.1.0496. (diff)
downloadvim-6e9cd6b491267e6dff3e3f3f37d8af5f28e40672.tar.xz
vim-6e9cd6b491267e6dff3e3f3f37d8af5f28e40672.zip
Adding upstream version 2:9.1.0698.upstream/2%9.1.0698
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/testdir/test_mapping.vim')
-rw-r--r--src/testdir/test_mapping.vim43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/testdir/test_mapping.vim b/src/testdir/test_mapping.vim
index 1175310..064f8ac 100644
--- a/src/testdir/test_mapping.vim
+++ b/src/testdir/test_mapping.vim
@@ -1767,6 +1767,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 assert_nobeep('call feedkeys("S\<C-R>a", "tx")')
+ call assert_equal('foo', getline('.'))
+
+ let @a = 'bar'
+ call assert_nobeep('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()