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