Mercurial > vim
annotate src/testdir/test_iminsert.vim @ 29123:81cef9a95000
Added tag v8.2.5081 for changeset bed794d67f72b785b142403ca670a46238d749b8
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 12 Jun 2022 23:45:03 +0200 |
parents | 54247d52bee9 |
children | 0b47ef4e19b8 |
rev | line source |
---|---|
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21128
diff
changeset
|
1 " Test for 'iminsert' |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21128
diff
changeset
|
2 |
12920
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 source view_util.vim |
18846
67eb9bc32434
patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents:
18008
diff
changeset
|
4 source check.vim |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
5 import './vim9.vim' as v9 |
12920
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 let s:imactivatefunc_called = 0 |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 let s:imstatusfunc_called = 0 |
18008
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
9 let s:imstatus_active = 0 |
12920
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 func IM_activatefunc(active) |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 let s:imactivatefunc_called = 1 |
20941
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
13 let s:imstatus_active = a:active |
12920
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 endfunc |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 func IM_statusfunc() |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 let s:imstatusfunc_called = 1 |
18008
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
18 return s:imstatus_active |
12920
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 endfunc |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 func Test_iminsert2() |
18008
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
22 let s:imactivatefunc_called = 0 |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
23 let s:imstatusfunc_called = 0 |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
24 |
12920
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 set imactivatefunc=IM_activatefunc |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 set imstatusfunc=IM_statusfunc |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 set iminsert=2 |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 normal! i |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 set iminsert=0 |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 set imactivatefunc= |
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 set imstatusfunc= |
12936
c53a80f39a52
patch 8.0.1344: using 'imactivatefunc' in the GUI does not work
Christian Brabandt <cb@256bit.org>
parents:
12930
diff
changeset
|
32 |
21128
484c27f2e98c
patch 8.2.1115: iminsert test fails when compiled with VIMDLL
Bram Moolenaar <Bram@vim.org>
parents:
21112
diff
changeset
|
33 let expected = (has('win32') && has('gui_running')) ? 0 : 1 |
12936
c53a80f39a52
patch 8.0.1344: using 'imactivatefunc' in the GUI does not work
Christian Brabandt <cb@256bit.org>
parents:
12930
diff
changeset
|
34 call assert_equal(expected, s:imactivatefunc_called) |
c53a80f39a52
patch 8.0.1344: using 'imactivatefunc' in the GUI does not work
Christian Brabandt <cb@256bit.org>
parents:
12930
diff
changeset
|
35 call assert_equal(expected, s:imstatusfunc_called) |
12920
327e1264b9bf
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 endfunc |
18008
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
37 |
18846
67eb9bc32434
patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents:
18008
diff
changeset
|
38 func Test_getimstatus() |
67eb9bc32434
patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents:
18008
diff
changeset
|
39 if has('win32') |
67eb9bc32434
patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents:
18008
diff
changeset
|
40 CheckFeature multi_byte_ime |
21785
c346db463a59
patch 8.2.1442: outdated references to the Mac Carbon GUI
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
41 else |
18846
67eb9bc32434
patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents:
18008
diff
changeset
|
42 CheckFeature xim |
67eb9bc32434
patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents:
18008
diff
changeset
|
43 endif |
21128
484c27f2e98c
patch 8.2.1115: iminsert test fails when compiled with VIMDLL
Bram Moolenaar <Bram@vim.org>
parents:
21112
diff
changeset
|
44 if has('win32') && has('gui_running') |
18008
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
45 set imactivatefunc= |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
46 set imstatusfunc= |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
47 else |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
48 set imactivatefunc=IM_activatefunc |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
49 set imstatusfunc=IM_statusfunc |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
50 let s:imstatus_active = 0 |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
51 endif |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
52 |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
53 new |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
54 set iminsert=2 |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
55 call feedkeys("i\<C-R>=getimstatus()\<CR>\<ESC>", 'nx') |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
56 call assert_equal('1', getline(1)) |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
57 set iminsert=0 |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
58 call feedkeys("o\<C-R>=getimstatus()\<CR>\<ESC>", 'nx') |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
59 call assert_equal('0', getline(2)) |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
60 bw! |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
61 |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
62 set imactivatefunc= |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
63 set imstatusfunc= |
8ae333756614
patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
64 endfunc |
19570
43c04edcafec
patch 8.2.0342: some code in ex_getln.c not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
18846
diff
changeset
|
65 |
28996
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
66 func Test_imactivatefunc_imstatusfunc_callback_no_breaks_foldopen() |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
67 CheckScreendump |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
68 |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
69 let lines =<< trim END |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
70 func IM_activatefunc(active) |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
71 endfunc |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
72 func IM_statusfunc() |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
73 return 0 |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
74 endfunc |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
75 set imactivatefunc=IM_activatefunc |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
76 set imstatusfunc=IM_statusfunc |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
77 set foldmethod=marker |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
78 set foldopen=search |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
79 call setline(1, ['{{{', 'abc', '}}}']) |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
80 %foldclose |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
81 END |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
82 call writefile(lines, 'Xscript') |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
83 let buf = RunVimInTerminal('-S Xscript', {}) |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
84 call term_wait(buf) |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
85 call assert_notequal('abc', term_getline(buf, 2)) |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
86 call term_sendkeys(buf, "/abc\n") |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
87 call term_wait(buf) |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
88 call assert_equal('abc', term_getline(buf, 2)) |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
89 |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
90 " clean up |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
91 call StopVimInTerminal(buf) |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
92 call delete('Xscript') |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
93 endfunc |
54247d52bee9
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
94 |
19625
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
95 " Test for using an lmap in insert mode |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
96 func Test_lmap_in_insert_mode() |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
97 new |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
98 call setline(1, 'abc') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
99 lmap { w |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
100 set iminsert=1 |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
101 call feedkeys('r{', 'xt') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
102 call assert_equal('wbc', getline(1)) |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
103 set iminsert=2 |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
104 call feedkeys('$r{', 'xt') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
105 call assert_equal('wb{', getline(1)) |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
106 call setline(1, 'vim web') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
107 set iminsert=1 |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
108 call feedkeys('0f{', 'xt') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
109 call assert_equal(5, col('.')) |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
110 set iminsert& |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
111 lunmap { |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
112 close! |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
113 endfunc |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19570
diff
changeset
|
114 |
20941
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
115 " Test for using CTRL-^ to toggle iminsert in insert mode |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
116 func Test_iminsert_toggle() |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
117 CheckGui |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
118 if has('win32') |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
119 CheckFeature multi_byte_ime |
21785
c346db463a59
patch 8.2.1442: outdated references to the Mac Carbon GUI
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
120 else |
20941
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
121 CheckFeature xim |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
122 endif |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
123 if has('gui_running') && !has('win32') |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21128
diff
changeset
|
124 throw 'Skipped: works only in Win32 GUI version (for some reason)' |
20941
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
125 endif |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
126 new |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
127 let save_imdisable = &imdisable |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
128 let save_iminsert = &iminsert |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
129 set noimdisable |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
130 set iminsert=0 |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
131 exe "normal i\<C-^>" |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
132 call assert_equal(2, &iminsert) |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
133 exe "normal i\<C-^>" |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
134 call assert_equal(0, &iminsert) |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
135 let &iminsert = save_iminsert |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
136 let &imdisable = save_imdisable |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
137 close! |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
138 endfunc |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
139 |
26408
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
140 " Test for different ways of setting the 'imactivatefunc' and 'imstatusfunc' |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
141 " options |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
142 func Test_imactivatefunc_imstatusfunc_callback() |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
143 CheckNotMSWindows |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
144 func IMactivatefunc1(active) |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
145 let g:IMactivatefunc_called += 1 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
146 endfunc |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
147 func IMstatusfunc1() |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
148 let g:IMstatusfunc_called += 1 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
149 return 1 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
150 endfunc |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
151 set iminsert=2 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
152 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
153 let lines =<< trim END |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
154 LET g:IMactivatefunc_called = 0 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
155 LET g:IMstatusfunc_called = 0 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
156 |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
157 #" Test for using a function name |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
158 LET &imactivatefunc = 'g:IMactivatefunc1' |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
159 LET &imstatusfunc = 'g:IMstatusfunc1' |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
160 normal! i |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
161 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
162 #" Test for using a function() |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
163 set imactivatefunc=function('g:IMactivatefunc1') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
164 set imstatusfunc=function('g:IMstatusfunc1') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
165 normal! i |
26408
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
166 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
167 #" Using a funcref variable to set 'completefunc' |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
168 VAR Fn1 = function('g:IMactivatefunc1') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
169 LET &imactivatefunc = Fn1 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
170 VAR Fn2 = function('g:IMstatusfunc1') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
171 LET &imstatusfunc = Fn2 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
172 normal! i |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26408
diff
changeset
|
173 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
174 #" Using a string(funcref variable) to set 'completefunc' |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
175 LET &imactivatefunc = string(Fn1) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
176 LET &imstatusfunc = string(Fn2) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
177 normal! i |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
178 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
179 #" Test for using a funcref() |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
180 set imactivatefunc=funcref('g:IMactivatefunc1') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
181 set imstatusfunc=funcref('g:IMstatusfunc1') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
182 normal! i |
26408
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
183 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
184 #" Using a funcref variable to set 'imactivatefunc' |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
185 LET Fn1 = funcref('g:IMactivatefunc1') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
186 LET &imactivatefunc = Fn1 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
187 LET Fn2 = funcref('g:IMstatusfunc1') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
188 LET &imstatusfunc = Fn2 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
189 normal! i |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
190 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
191 #" Using a string(funcref variable) to set 'imactivatefunc' |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
192 LET &imactivatefunc = string(Fn1) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
193 LET &imstatusfunc = string(Fn2) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
194 normal! i |
26408
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
195 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
196 #" Test for using a lambda function |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
197 VAR optval = "LSTART a LMIDDLE g:IMactivatefunc1(a) LEND" |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
198 LET optval = substitute(optval, ' ', '\\ ', 'g') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
199 exe "set imactivatefunc=" .. optval |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
200 LET optval = "LSTART LMIDDLE g:IMstatusfunc1() LEND" |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
201 LET optval = substitute(optval, ' ', '\\ ', 'g') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
202 exe "set imstatusfunc=" .. optval |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
203 normal! i |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26408
diff
changeset
|
204 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
205 #" Set 'imactivatefunc' and 'imstatusfunc' to a lambda expression |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
206 LET &imactivatefunc = LSTART a LMIDDLE g:IMactivatefunc1(a) LEND |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
207 LET &imstatusfunc = LSTART LMIDDLE g:IMstatusfunc1() LEND |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
208 normal! i |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
209 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
210 #" Set 'imactivatefunc' and 'imstatusfunc' to a string(lambda expression) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
211 LET &imactivatefunc = 'LSTART a LMIDDLE g:IMactivatefunc1(a) LEND' |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
212 LET &imstatusfunc = 'LSTART LMIDDLE g:IMstatusfunc1() LEND' |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
213 normal! i |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
214 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
215 #" Set 'imactivatefunc' 'imstatusfunc' to a variable with a lambda |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
216 #" expression |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
217 VAR Lambda1 = LSTART a LMIDDLE g:IMactivatefunc1(a) LEND |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
218 VAR Lambda2 = LSTART LMIDDLE g:IMstatusfunc1() LEND |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
219 LET &imactivatefunc = Lambda1 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
220 LET &imstatusfunc = Lambda2 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
221 normal! i |
26408
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
222 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
223 #" Set 'imactivatefunc' 'imstatusfunc' to a string(variable with a lambda |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
224 #" expression) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
225 LET &imactivatefunc = string(Lambda1) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
226 LET &imstatusfunc = string(Lambda2) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
227 normal! i |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
228 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
229 #" Test for clearing the 'completefunc' option |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
230 set imactivatefunc='' imstatusfunc='' |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
231 set imactivatefunc& imstatusfunc& |
26408
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
232 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
233 set imactivatefunc=g:IMactivatefunc1 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
234 set imstatusfunc=g:IMstatusfunc1 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
235 call assert_fails("set imactivatefunc=function('abc')", "E700:") |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
236 call assert_fails("set imstatusfunc=function('abc')", "E700:") |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
237 call assert_fails("set imactivatefunc=funcref('abc')", "E700:") |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
238 call assert_fails("set imstatusfunc=funcref('abc')", "E700:") |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
239 call assert_fails("LET &imstatusfunc = function('abc')", "E700:") |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
240 call assert_fails("LET &imactivatefunc = function('abc')", "E700:") |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
241 normal! i |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26408
diff
changeset
|
242 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
243 #" set 'imactivatefunc' and 'imstatusfunc' to a non-existing function |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
244 set imactivatefunc=IMactivatefunc1 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
245 set imstatusfunc=IMstatusfunc1 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
246 call assert_fails("set imactivatefunc=function('NonExistingFunc')", 'E700:') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
247 call assert_fails("set imstatusfunc=function('NonExistingFunc')", 'E700:') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
248 call assert_fails("LET &imactivatefunc = function('NonExistingFunc')", 'E700:') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
249 call assert_fails("LET &imstatusfunc = function('NonExistingFunc')", 'E700:') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
250 normal! i |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
251 |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
252 call assert_equal(14, g:IMactivatefunc_called) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
253 call assert_equal(28, g:IMstatusfunc_called) |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
254 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
255 call v9.CheckLegacyAndVim9Success(lines) |
26408
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
256 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
257 " Using Vim9 lambda expression in legacy context should fail |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
258 set imactivatefunc=(a)\ =>\ IMactivatefunc1(a) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
259 set imstatusfunc=IMstatusfunc1 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
260 call assert_fails('normal! i', 'E117:') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
261 set imactivatefunc=IMactivatefunc1 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
262 set imstatusfunc=()\ =>\ IMstatusfunc1(a) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
263 call assert_fails('normal! i', 'E117:') |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26408
diff
changeset
|
264 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
265 " set 'imactivatefunc' and 'imstatusfunc' to a partial with dict. This used |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
266 " to cause a crash. |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
267 func SetIMFunc() |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
268 let params1 = {'activate': function('g:DictActivateFunc')} |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
269 let params2 = {'status': function('g:DictStatusFunc')} |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
270 let &imactivatefunc = params1.activate |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
271 let &imstatusfunc = params2.status |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
272 endfunc |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
273 func g:DictActivateFunc(_) dict |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
274 endfunc |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
275 func g:DictStatusFunc(_) dict |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
276 endfunc |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
277 call SetIMFunc() |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
278 new |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
279 call SetIMFunc() |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
280 bw |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
281 call test_garbagecollect_now() |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
282 new |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
283 set imactivatefunc= |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
284 set imstatusfunc= |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
285 wincmd w |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
286 set imactivatefunc= |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
287 set imstatusfunc= |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
288 :%bw! |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
289 delfunc g:DictActivateFunc |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
290 delfunc g:DictStatusFunc |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
291 delfunc SetIMFunc |
26408
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
292 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
293 " Vim9 tests |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
294 let lines =<< trim END |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
295 vim9script |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
296 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
297 # Test for using function() |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
298 def IMactivatefunc1(active: number): any |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
299 g:IMactivatefunc_called += 1 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
300 return 1 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
301 enddef |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
302 def IMstatusfunc1(): number |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
303 g:IMstatusfunc_called += 1 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
304 return 1 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
305 enddef |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
306 g:IMactivatefunc_called = 0 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
307 g:IMstatusfunc_called = 0 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
308 set iminsert=2 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
309 set imactivatefunc=function('IMactivatefunc1') |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
310 set imstatusfunc=function('IMstatusfunc1') |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
311 normal! i |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
312 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
313 set iminsert=0 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
314 set imactivatefunc= |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
315 set imstatusfunc= |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
316 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
317 call v9.CheckScriptSuccess(lines) |
26408
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
318 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
319 " cleanup |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
320 set iminsert=0 |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
321 set imactivatefunc& |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
322 set imstatusfunc& |
26408
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
323 delfunc IMactivatefunc1 |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
324 delfunc IMstatusfunc1 |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
325 unlet g:IMactivatefunc_called g:IMstatusfunc_called |
26408
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
326 %bw! |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
327 endfunc |
8f17f8f327f3
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
328 |
19570
43c04edcafec
patch 8.2.0342: some code in ex_getln.c not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
18846
diff
changeset
|
329 " vim: shiftwidth=2 sts=2 expandtab |