Mercurial > vim
comparison src/testdir/test_mapping.vim @ 15659:8513d9864f7e v8.1.0837
patch 8.1.0837: timer interrupting cursorhold and mapping not tested
commit https://github.com/vim/vim/commit/26d982185e21398738a9c688429c0a1840d7c9c3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 27 22:32:55 2019 +0100
patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Problem: Timer interrupting cursorhold and mapping not tested.
Solution: Add tests with timers. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/3871)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 27 Jan 2019 22:45:05 +0100 |
parents | 2dcaa860e3fc |
children | cb501b3c9fb5 |
comparison
equal
deleted
inserted
replaced
15658:baf0958cbef4 | 15659:8513d9864f7e |
---|---|
1 " Tests for mappings and abbreviations | 1 " Tests for mappings and abbreviations |
2 | |
3 source shared.vim | |
2 | 4 |
3 func Test_abbreviation() | 5 func Test_abbreviation() |
4 " abbreviation with 0x80 should work | 6 " abbreviation with 0x80 should work |
5 inoreab чкпр vim | 7 inoreab чкпр vim |
6 call feedkeys("Goчкпр \<Esc>", "xt") | 8 call feedkeys("Goчкпр \<Esc>", "xt") |
167 unabbr foo | 169 unabbr foo |
168 set backspace& | 170 set backspace& |
169 endfunc | 171 endfunc |
170 | 172 |
171 func Test_map_timeout() | 173 func Test_map_timeout() |
174 if !has('timers') | |
175 return | |
176 endif | |
172 nnoremap aaaa :let got_aaaa = 1<CR> | 177 nnoremap aaaa :let got_aaaa = 1<CR> |
173 nnoremap bb :let got_bb = 1<CR> | 178 nnoremap bb :let got_bb = 1<CR> |
174 nmap b aaa | 179 nmap b aaa |
175 new | 180 new |
176 func ExitInsert(timer) | 181 func ExitInsert(timer) |
177 let g:line = getline(1) | 182 let g:line = getline(1) |
178 call feedkeys("\<Esc>", "t") | 183 call feedkeys("\<Esc>", "t") |
179 endfunc | 184 endfunc |
180 set timeout timeoutlen=200 | 185 set timeout timeoutlen=200 |
181 call timer_start(300, 'ExitInsert') | 186 let timer = timer_start(300, 'ExitInsert') |
182 " After the 'b' Vim waits for another character to see if it matches 'bb'. | 187 " After the 'b' Vim waits for another character to see if it matches 'bb'. |
183 " When it times out it is expanded to "aaa", but there is no wait for | 188 " When it times out it is expanded to "aaa", but there is no wait for |
184 " "aaaa". Can't check that reliably though. | 189 " "aaaa". Can't check that reliably though. |
185 call feedkeys("b", "xt!") | 190 call feedkeys("b", "xt!") |
186 call assert_equal("aa", g:line) | 191 call assert_equal("aa", g:line) |
191 nunmap aaaa | 196 nunmap aaaa |
192 nunmap bb | 197 nunmap bb |
193 nunmap b | 198 nunmap b |
194 set timeoutlen& | 199 set timeoutlen& |
195 delfunc ExitInsert | 200 delfunc ExitInsert |
201 call timer_stop(timer) | |
202 endfunc | |
203 | |
204 func Test_map_timeout_with_timer_interrupt() | |
205 if !has('job') || !has('timers') | |
206 return | |
207 endif | |
208 | |
209 " Confirm the timer invoked in exit_cb of the job doesn't disturb mapped key | |
210 " sequence. | |
211 new | |
212 let g:val = 0 | |
213 nnoremap \12 :let g:val = 1<CR> | |
214 nnoremap \123 :let g:val = 2<CR> | |
215 set timeout timeoutlen=1000 | |
216 | |
217 func ExitCb(job, status) | |
218 let g:timer = timer_start(1, {_ -> feedkeys("3\<Esc>", 't')}) | |
219 endfunc | |
220 | |
221 call job_start([&shell, &shellcmdflag, 'echo'], {'exit_cb': 'ExitCb'}) | |
222 call feedkeys('\12', 'xt!') | |
223 call assert_equal(2, g:val) | |
224 | |
225 bwipe! | |
226 nunmap \12 | |
227 nunmap \123 | |
228 set timeoutlen& | |
229 call WaitFor({-> exists('g:timer')}) | |
230 call timer_stop(g:timer) | |
231 unlet g:timer | |
232 unlet g:val | |
233 delfunc ExitCb | |
196 endfunc | 234 endfunc |
197 | 235 |
198 func Test_abbreviation_CR() | 236 func Test_abbreviation_CR() |
199 new | 237 new |
200 func Eatchar(pat) | 238 func Eatchar(pat) |