Mercurial > vim
diff 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 |
line wrap: on
line diff
--- a/src/testdir/test_iminsert.vim +++ b/src/testdir/test_iminsert.vim @@ -2,17 +2,22 @@ source view_util.vim let s:imactivatefunc_called = 0 let s:imstatusfunc_called = 0 +let s:imstatus_active = 0 func IM_activatefunc(active) let s:imactivatefunc_called = 1 +let s:imstatus_active = a:active endfunc func IM_statusfunc() let s:imstatusfunc_called = 1 - return 0 + return s:imstatus_active endfunc func Test_iminsert2() + let s:imactivatefunc_called = 0 + let s:imstatusfunc_called = 0 + set imactivatefunc=IM_activatefunc set imstatusfunc=IM_statusfunc set iminsert=2 @@ -25,3 +30,29 @@ func Test_iminsert2() call assert_equal(expected, s:imactivatefunc_called) call assert_equal(expected, s:imstatusfunc_called) endfunc + +func Test_imgetstatus() + if has('gui_running') + if !has('win32') + throw 'Skipped: running in the GUI, only works on MS-Windows' + endif + set imactivatefunc= + set imstatusfunc= + else + set imactivatefunc=IM_activatefunc + set imstatusfunc=IM_statusfunc + let s:imstatus_active = 0 + endif + + new + set iminsert=2 + call feedkeys("i\<C-R>=getimstatus()\<CR>\<ESC>", 'nx') + call assert_equal('1', getline(1)) + set iminsert=0 + call feedkeys("o\<C-R>=getimstatus()\<CR>\<ESC>", 'nx') + call assert_equal('0', getline(2)) + bw! + + set imactivatefunc= + set imstatusfunc= +endfunc