comparison src/testdir/test_iminsert.vim @ 18008:8ae333756614 v8.1.2000

patch 8.1.2000: plugin cannot get the current IME status Commit: https://github.com/vim/vim/commit/a3a124627d2eb9d36e3dc3757429d87e041f8c0b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 7 15:08:38 2019 +0200 patch 8.1.2000: plugin cannot get the current IME status Problem: Plugin cannot get the current IME status. Solution: Add the getimstatus() function. (closes https://github.com/vim/vim/issues/4904)
author Bram Moolenaar <Bram@vim.org>
date Sat, 07 Sep 2019 15:15:04 +0200
parents 2dcaa860e3fc
children 67eb9bc32434
comparison
equal deleted inserted replaced
18007:3558fd8f7a92 18008:8ae333756614
1 source view_util.vim 1 source view_util.vim
2 2
3 let s:imactivatefunc_called = 0 3 let s:imactivatefunc_called = 0
4 let s:imstatusfunc_called = 0 4 let s:imstatusfunc_called = 0
5 let s:imstatus_active = 0
5 6
6 func IM_activatefunc(active) 7 func IM_activatefunc(active)
7 let s:imactivatefunc_called = 1 8 let s:imactivatefunc_called = 1
9 let s:imstatus_active = a:active
8 endfunc 10 endfunc
9 11
10 func IM_statusfunc() 12 func IM_statusfunc()
11 let s:imstatusfunc_called = 1 13 let s:imstatusfunc_called = 1
12 return 0 14 return s:imstatus_active
13 endfunc 15 endfunc
14 16
15 func Test_iminsert2() 17 func Test_iminsert2()
18 let s:imactivatefunc_called = 0
19 let s:imstatusfunc_called = 0
20
16 set imactivatefunc=IM_activatefunc 21 set imactivatefunc=IM_activatefunc
17 set imstatusfunc=IM_statusfunc 22 set imstatusfunc=IM_statusfunc
18 set iminsert=2 23 set iminsert=2
19 normal! i 24 normal! i
20 set iminsert=0 25 set iminsert=0
23 28
24 let expected = has('gui_running') ? 0 : 1 29 let expected = has('gui_running') ? 0 : 1
25 call assert_equal(expected, s:imactivatefunc_called) 30 call assert_equal(expected, s:imactivatefunc_called)
26 call assert_equal(expected, s:imstatusfunc_called) 31 call assert_equal(expected, s:imstatusfunc_called)
27 endfunc 32 endfunc
33
34 func Test_imgetstatus()
35 if has('gui_running')
36 if !has('win32')
37 throw 'Skipped: running in the GUI, only works on MS-Windows'
38 endif
39 set imactivatefunc=
40 set imstatusfunc=
41 else
42 set imactivatefunc=IM_activatefunc
43 set imstatusfunc=IM_statusfunc
44 let s:imstatus_active = 0
45 endif
46
47 new
48 set iminsert=2
49 call feedkeys("i\<C-R>=getimstatus()\<CR>\<ESC>", 'nx')
50 call assert_equal('1', getline(1))
51 set iminsert=0
52 call feedkeys("o\<C-R>=getimstatus()\<CR>\<ESC>", 'nx')
53 call assert_equal('0', getline(2))
54 bw!
55
56 set imactivatefunc=
57 set imstatusfunc=
58 endfunc