@@ -35,29 +35,73 @@ func Test_map_ctrl_c_visual()
3535endfunc
3636
3737func Test_map_langmap ()
38- " langmap should not get remapped in insert mode
39- inoremap { FAIL_ilangmap
40- set langmap = + { langnoremap
38+ if ! has (' langmap' )
39+ return
40+ endif
41+
42+ " check langmap applies in normal mode
43+ set langmap = +- nolangremap
44+ new
45+ call setline (1 , [' a' , ' b' , ' c' ])
46+ 2
47+ call assert_equal (' b' , getline (' .' ))
48+ call feedkeys (" +" , " xt" )
49+ call assert_equal (' a' , getline (' .' ))
50+
51+ " check no remapping
52+ map x +
53+ 2
54+ call feedkeys (" x" , " xt" )
55+ call assert_equal (' c' , getline (' .' ))
56+
57+ " check with remapping
58+ set langremap
59+ 2
60+ call feedkeys (" x" , " xt" )
61+ call assert_equal (' a' , getline (' .' ))
62+
63+ unmap x
64+ bwipe!
65+
66+ " 'langnoremap' follows 'langremap' and vise versa
67+ set langremap
68+ set langnoremap
69+ call assert_equal (0 , &langremap )
70+ set langremap
71+ call assert_equal (0 , &langnoremap )
72+ set nolangremap
73+ call assert_equal (1 , &langnoremap )
74+
75+ " langmap should not apply in insert mode, 'langremap' doesn't matter
76+ set langmap = + { nolangremap
4177 call feedkeys (" Go+\<Esc> " , " xt" )
4278 call assert_equal (' +' , getline (' $' ))
43-
44- " Insert-mode expr mapping with langmap
45- inoremap <expr> { "FAIL_iexplangmap"
79+ set langmap = + { langremap
4680 call feedkeys (" Go+\<Esc> " , " xt" )
4781 call assert_equal (' +' , getline (' $' ))
48- iunmap <expr> {
4982
50- " langmap should not get remapped in Command-line mode
51- cnoremap { FAIL_clangmap
83+ " langmap used for register name in insert mode.
84+ call setreg (' a' , ' aaaa' )
85+ call setreg (' b' , ' bbbb' )
86+ call setreg (' c' , ' cccc' )
87+ set langmap = ab langremap
88+ call feedkeys (" Go\<C-R> a\<Esc> " , " xt" )
89+ call assert_equal (' bbbb' , getline (' $' ))
90+ call feedkeys (" Go\<C-R>\<C-R> a\<Esc> " , " xt" )
91+ call assert_equal (' bbbb' , getline (' $' ))
92+ " mapping does not apply
93+ imap c a
94+ call feedkeys (" Go\<C-R> c\<Esc> " , " xt" )
95+ call assert_equal (' cccc' , getline (' $' ))
96+ imap a c
97+ call feedkeys (" Go\<C-R> a\<Esc> " , " xt" )
98+ call assert_equal (' bbbb' , getline (' $' ))
99+
100+ " langmap should not apply in Command-line mode
101+ set langmap = + { nolangremap
52102 call feedkeys (" :call append(line('$'), '+')\<CR> " , " xt" )
53103 call assert_equal (' +' , getline (' $' ))
54- cunmap {
55104
56- " Command-line mode expr mapping with langmap
57- cnoremap <expr> { "FAIL_cexplangmap"
58- call feedkeys (" :call append(line('$'), '+')\<CR> " , " xt" )
59- call assert_equal (' +' , getline (' $' ))
60- cunmap {
61105 set nomodified
62106endfunc
63107
0 commit comments