annotate src/testdir/test_iminsert.vim @ 26441:65ab0b035dd8 v8.2.3751

patch 8.2.3751: cannot assign a lambda to an option that takes a function Commit: https://github.com/vim/vim/commit/6409553b6e3b4de4e1d72b8ee5445595214581ff Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Dec 6 11:03:55 2021 +0000 patch 8.2.3751: cannot assign a lambda to an option that takes a function Problem: Cannot assign a lambda to an option that takes a function. Solution: Automatically convert the lambda to a string. (Yegappan Lakshmanan, closes #9286)
author Bram Moolenaar <Bram@vim.org>
date Mon, 06 Dec 2021 12:15:04 +0100
parents 8f17f8f327f3
children 65b4109a4297
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
5 source vim9.vim
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
19625
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
66 " 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
67 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
68 new
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
69 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
70 lmap { w
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
71 set iminsert=1
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
72 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
73 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
74 set iminsert=2
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
75 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
76 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
77 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
78 set iminsert=1
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
79 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
80 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
81 set iminsert&
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
82 lunmap {
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
83 close!
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
84 endfunc
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
85
20941
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
86 " 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
87 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
88 CheckGui
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
89 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
90 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
91 else
20941
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
92 CheckFeature xim
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
93 endif
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
94 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
95 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
96 endif
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
97 new
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
98 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
99 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
100 set noimdisable
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108 close!
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
109 endfunc
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
110
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
111 " 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
112 " options
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
113 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
114 CheckNotMSWindows
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
115 func IMactivatefunc1(active)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
116 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
117 endfunc
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
118 func IMstatusfunc1()
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
119 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
120 return 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
121 endfunc
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
122 let g:IMactivatefunc_called = 0
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
123 let g:IMstatusfunc_called = 0
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
124 set iminsert=2
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
125
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
126 " Test for using a function()
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
127 set imactivatefunc=function('IMactivatefunc1')
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
128 set imstatusfunc=function('IMstatusfunc1')
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
129 normal! i
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
130
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
131 " Using a funcref variable to set 'completefunc'
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
132 let Fn1 = function('IMactivatefunc1')
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
133 let &imactivatefunc = Fn1
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
134 let Fn2 = function('IMstatusfunc1')
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
135 let &imstatusfunc = Fn2
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
136 normal! i
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
137
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
138 " Using a string(funcref variable) to set 'completefunc'
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
139 let &imactivatefunc = string(Fn1)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
140 let &imstatusfunc = string(Fn2)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
141 normal! i
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
142
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
143 " Test for using a funcref()
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
144 set imactivatefunc=funcref('IMactivatefunc1')
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
145 set imstatusfunc=funcref('IMstatusfunc1')
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
146 normal! i
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
147
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
148 " Using a funcref variable to set 'imactivatefunc'
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
149 let Fn1 = funcref('IMactivatefunc1')
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
150 let &imactivatefunc = Fn1
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
151 let Fn2 = funcref('IMstatusfunc1')
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
152 let &imstatusfunc = Fn2
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
153 normal! i
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
154
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
155 " Using a string(funcref variable) to set 'imactivatefunc'
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
156 let &imactivatefunc = string(Fn1)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
157 let &imstatusfunc = string(Fn2)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
158 normal! i
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
159
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
160 " Test for using a lambda function
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
161 set imactivatefunc={a\ ->\ IMactivatefunc1(a)}
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
162 set imstatusfunc={\ ->\ IMstatusfunc1()}
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
163 normal! i
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
164
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
165 " Set 'imactivatefunc' and 'imstatusfunc' to a lambda expression
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
166 let &imactivatefunc = {a -> IMactivatefunc1(a)}
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
167 let &imstatusfunc = { -> IMstatusfunc1()}
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
168 normal! i
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
169
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
170 " Set 'imactivatefunc' and 'imstatusfunc' to a string(lambda expression)
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
171 let &imactivatefunc = '{a -> IMactivatefunc1(a)}'
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
172 let &imstatusfunc = '{ -> IMstatusfunc1()}'
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
173 normal! i
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
174
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
175 " Set 'imactivatefunc' 'imstatusfunc' to a variable with a lambda expression
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
176 let Lambda1 = {a -> IMactivatefunc1(a)}
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
177 let Lambda2 = { -> IMstatusfunc1()}
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
178 let &imactivatefunc = Lambda1
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
179 let &imstatusfunc = Lambda2
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
180 normal! i
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
181
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
182 " Set 'imactivatefunc' 'imstatusfunc' to a string(variable with a lambda
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
183 " expression)
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
184 let &imactivatefunc = string(Lambda1)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
185 let &imstatusfunc = string(Lambda2)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
186 normal! i
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
187
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
188 " Test for clearing the 'completefunc' option
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
189 set imactivatefunc='' imstatusfunc=''
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
190 set imactivatefunc& imstatusfunc&
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
191
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
192 call assert_fails("set imactivatefunc=function('abc')", "E700:")
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
193 call assert_fails("set imstatusfunc=function('abc')", "E700:")
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
194 call assert_fails("set imactivatefunc=funcref('abc')", "E700:")
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
195 call assert_fails("set imstatusfunc=funcref('abc')", "E700:")
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
196
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
197 call assert_equal(11, g:IMactivatefunc_called)
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
198 call assert_equal(22, g:IMstatusfunc_called)
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
199
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
200 " Vim9 tests
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
201 let lines =<< trim END
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
202 vim9script
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
203
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
204 # Test for using function()
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
205 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
206 g:IMactivatefunc_called += 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
207 return 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
208 enddef
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
209 def IMstatusfunc1(): number
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
210 g:IMstatusfunc_called += 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
211 return 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
212 enddef
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
213 g:IMactivatefunc_called = 0
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
214 g:IMstatusfunc_called = 0
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
215 set iminsert=2
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
216 set imactivatefunc=function('IMactivatefunc1')
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
217 set imstatusfunc=function('IMstatusfunc1')
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
218 normal! i
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
219
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
220 # Test for using a lambda
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
221 &imactivatefunc = '(a) => IMactivatefunc1(a)'
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
222 &imstatusfunc = '() => IMstatusfunc1()'
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
223 normal! i
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
224
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
225 # Test for using a variable with a lambda expression
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
226 var Fn1: func = (active) => {
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
227 g:IMactivatefunc_called += 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
228 return 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
229 }
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
230 var Fn2: func = () => {
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
231 g:IMstatusfunc_called += 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
232 return 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
233 }
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
234 &imactivatefunc = Fn1
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
235 &imstatusfunc = Fn2
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
236 normal! i
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
237
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
238 # Test for using a string(variable with a lambda expression)
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
239 &imactivatefunc = string(Fn1)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
240 &imstatusfunc = string(Fn2)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
241 normal! i
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
242
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
243 assert_equal(4, g:IMactivatefunc_called)
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
244 assert_equal(8, g:IMstatusfunc_called)
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
245
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
246 set iminsert=0
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
247 set imactivatefunc=
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
248 set imstatusfunc=
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
249 END
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
250 call CheckScriptSuccess(lines)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
251
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
252 " Using Vim9 lambda expression in legacy context should fail
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
253 set imactivatefunc=(a)\ =>\ IMactivatefunc1(a)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
254 set imstatusfunc=IMstatusfunc1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
255 call assert_fails('normal! i', 'E117:')
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
256 set imactivatefunc=IMactivatefunc1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
257 set imstatusfunc=()\ =>\ IMstatusfunc1(a)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
258 call assert_fails('normal! i', 'E117:')
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
259
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
260 " cleanup
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
261 delfunc IMactivatefunc1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
262 delfunc IMstatusfunc1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
263 set iminsert=0
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
264 set imactivatefunc=
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
265 set imstatusfunc=
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
266
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
267 %bw!
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
268 endfunc
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
269
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
270 " vim: shiftwidth=2 sts=2 expandtab