comparison src/testdir/test_maparg.vim @ 20516:d9e3fdf26cb9 v8.2.0812

patch 8.2.0812: mapset() does not properly handle <> notation Commit: https://github.com/vim/vim/commit/c94c1467b9b86156a6b7c8d3e41ff01c13d2be07 Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 22 20:01:06 2020 +0200 patch 8.2.0812: mapset() does not properly handle <> notation Problem: mapset() does not properly handle <> notation. Solution: Convert <> codes. (closes https://github.com/vim/vim/issues/6116)
author Bram Moolenaar <Bram@vim.org>
date Fri, 22 May 2020 20:15:03 +0200
parents aee0b72ca6d6
children 729853a754ea
comparison
equal deleted inserted replaced
20515:313bff7c3f01 20516:d9e3fdf26cb9
4 4
5 func s:SID() 5 func s:SID()
6 return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')) 6 return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$'))
7 endfunc 7 endfunc
8 8
9 funct Test_maparg() 9 func Test_maparg()
10 new 10 new
11 set cpo-=< 11 set cpo-=<
12 set encoding=utf8 12 set encoding=utf8
13 " Test maparg() with a string result 13 " Test maparg() with a string result
14 let sid = s:SID() 14 let sid = s:SID()
154 endfunc 154 endfunc
155 155
156 func Test_mapset() 156 func Test_mapset()
157 call One_mapset_test('K') 157 call One_mapset_test('K')
158 call One_mapset_test('<F3>') 158 call One_mapset_test('<F3>')
159
160 " Check <> key conversion
161 new
162 inoremap K one<Left>x
163 call feedkeys("iK\<Esc>", 'xt')
164 call assert_equal('onxe', getline(1))
165
166 let orig = maparg('K', 'i', 0, 1)
167 call assert_equal('K', orig.lhs)
168 call assert_equal('one<Left>x', orig.rhs)
169 call assert_equal('i', orig.mode)
170
171 iunmap K
172 let d = maparg('K', 'i', 0, 1)
173 call assert_equal({}, d)
174
175 call mapset('i', 0, orig)
176 call feedkeys("SK\<Esc>", 'xt')
177 call assert_equal('onxe', getline(1))
178
179 iunmap K
180
181 " Test literal <CR> using a backslash
182 let cpo_save = &cpo
183 set cpo-=B
184 inoremap K one\<CR>two
185 call feedkeys("SK\<Esc>", 'xt')
186 call assert_equal('one<CR>two', getline(1))
187
188 let orig = maparg('K', 'i', 0, 1)
189 call assert_equal('K', orig.lhs)
190 call assert_equal('one\<CR>two', orig.rhs)
191 call assert_equal('i', orig.mode)
192
193 iunmap K
194 let d = maparg('K', 'i', 0, 1)
195 call assert_equal({}, d)
196
197 call mapset('i', 0, orig)
198 call feedkeys("SK\<Esc>", 'xt')
199 call assert_equal('one<CR>two', getline(1))
200
201 iunmap K
202 let &cpo = cpo_save
203
204 " Test literal <CR> using CTRL-V
205 inoremap K one<CR>two
206 call feedkeys("SK\<Esc>", 'xt')
207 call assert_equal('one<CR>two', getline(1))
208
209 let orig = maparg('K', 'i', 0, 1)
210 call assert_equal('K', orig.lhs)
211 call assert_equal("one\x16<CR>two", orig.rhs)
212 call assert_equal('i', orig.mode)
213
214 iunmap K
215 let d = maparg('K', 'i', 0, 1)
216 call assert_equal({}, d)
217
218 call mapset('i', 0, orig)
219 call feedkeys("SK\<Esc>", 'xt')
220 call assert_equal('one<CR>two', getline(1))
221
222 iunmap K
223 let &cpo = cpo_save
224
225 bwipe!
159 endfunc 226 endfunc
160 227
161 " vim: shiftwidth=2 sts=2 expandtab 228 " vim: shiftwidth=2 sts=2 expandtab