annotate src/testdir/test_iminsert.vim @ 27457:4c16acb2525f v8.2.4257

patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent Commit: https://github.com/vim/vim/commit/62aec93bfdb9e1b40d03a6d2e8e9511f8b1bdb2d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 29 21:45:34 2022 +0000 patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent Problem: Vim9: finding global function without g: prefix but not finding global variable is inconsistent. Solution: Require using g: for a global function. Change the vim9.vim script into a Vim9 script with exports. Fix that import in legacy script does not work.
author Bram Moolenaar <Bram@vim.org>
date Sat, 29 Jan 2022 23:00:05 +0100
parents 33d680d372aa
children 54247d52bee9
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
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
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 set iminsert=2
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
123
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
124 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
125 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
126 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
127
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
128 #" 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
129 LET &imactivatefunc = 'g:IMactivatefunc1'
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
130 LET &imstatusfunc = 'g:IMstatusfunc1'
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
131 normal! i
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
132
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
133 #" 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
134 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
135 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
136 normal! i
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
137
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
138 #" 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
139 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
140 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
141 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
142 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
143 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
144
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
145 #" 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
146 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
147 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
148 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
149
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
150 #" 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
151 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
152 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
153 normal! i
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
154
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
155 #" 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
156 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
157 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
158 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
159 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
160 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
161
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 #" 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
163 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
164 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
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 #" 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
168 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
169 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
170 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
171 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
172 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
173 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
174 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
175
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
176 #" 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
177 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
178 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
179 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
180
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 '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
182 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
183 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
184 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
185
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 #" 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
187 #" expression
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
188 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
189 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
190 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
191 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
192 normal! i
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
193
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
194 #" 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
195 #" 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
196 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
197 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
198 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
199
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
200 #" 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
201 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
202 set imactivatefunc& imstatusfunc&
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
203
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
204 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
205 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
206 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
207 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
208 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
209 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
210 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
211 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
212 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
213
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
214 #" 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
215 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
216 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
217 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
218 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
219 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
220 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
221 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
222
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
223 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
224 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
225 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
226 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
227
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
228 " 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
229 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
230 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
231 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
232 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
233 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
234 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
235
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
236 " 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
237 " 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
238 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
239 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
240 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
241 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
242 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
243 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
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 :%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
260 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
261 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
262 delfunc SetIMFunc
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
263
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
264 " Vim9 tests
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
265 let lines =<< trim END
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
266 vim9script
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
267
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
268 # Test for using function()
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
269 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
270 g:IMactivatefunc_called += 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
271 return 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
272 enddef
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
273 def IMstatusfunc1(): number
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
274 g:IMstatusfunc_called += 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
275 return 1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
276 enddef
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
277 g:IMactivatefunc_called = 0
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
278 g:IMstatusfunc_called = 0
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
279 set iminsert=2
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
280 set imactivatefunc=function('IMactivatefunc1')
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
281 set imstatusfunc=function('IMstatusfunc1')
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
282 normal! i
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
283
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
284 set iminsert=0
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
285 set imactivatefunc=
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
286 set imstatusfunc=
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
287 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
288 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
289
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
290 " cleanup
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
291 set iminsert=0
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
292 set imactivatefunc&
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
293 set imstatusfunc&
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
294 delfunc IMactivatefunc1
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
295 delfunc IMstatusfunc1
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
296 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
297 %bw!
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
298 endfunc
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
299
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
300 " vim: shiftwidth=2 sts=2 expandtab