annotate src/testdir/test_execute_func.vim @ 29692:042f357b455d v9.0.0186

patch 9.0.0186: virtual text without highlighting does not show Commit: https://github.com/vim/vim/commit/3331dd03515655ec6b9c1bd374db6e8c27acb27a Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 10 16:49:02 2022 +0100 patch 9.0.0186: virtual text without highlighting does not show Problem: Virtual text without highlighting does not show. (Ben Jackson) Solution: Use a text property when it has highlighting or when it has text. (closes #10878)
author Bram Moolenaar <Bram@vim.org>
date Wed, 10 Aug 2022 18:00:04 +0200
parents 4c16acb2525f
children 029c59bf78f1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9454
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " test execute()
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
18259
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
3 source view_util.vim
18767
068337e86133 patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents: 18763
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: 26994
diff changeset
5 import './vim9.vim' as v9
26666
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
6 source term_util.vim
18259
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
7
9454
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 func NestedEval()
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 let nested = execute('echo "nested\nlines"')
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 echo 'got: "' . nested . '"'
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 endfunc
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 func NestedRedir()
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 redir => var
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 echo 'broken'
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 redir END
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 endfunc
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 func Test_execute_string()
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal("\nnocompatible", execute('set compatible?'))
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 call assert_equal("\nsomething\nnice", execute('echo "something\nnice"'))
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call assert_equal("noendofline", execute('echon "noendofline"'))
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal("", execute(123))
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call assert_equal("\ngot: \"\nnested\nlines\"", execute('call NestedEval()'))
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 redir => redired
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 echo 'this'
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 let evaled = execute('echo "that"')
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 echo 'theend'
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 redir END
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call assert_equal("\nthis\ntheend", redired)
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call assert_equal("\nthat", evaled)
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 call assert_fails('call execute("doesnotexist")', 'E492:')
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 call assert_fails('call execute("call NestedRedir()")', 'E930:')
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 call assert_equal("\nsomething", execute('echo "something"', ''))
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 call assert_equal("\nsomething", execute('echo "something"', 'silent'))
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 call assert_equal("\nsomething", execute('echo "something"', 'silent!'))
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call assert_equal("", execute('burp', 'silent!'))
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19085
diff changeset
41 if has('float')
24822
5f8dd7b3ae41 patch 8.2.2949: tests failing because no error for float to string conversion
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
42 call assert_fails('call execute(3.4)', 'E492:')
5f8dd7b3ae41 patch 8.2.2949: tests failing because no error for float to string conversion
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
43 call assert_equal("\nx", execute("echo \"x\"", 3.4))
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26994
diff changeset
44 call v9.CheckDefExecAndScriptFailure(['execute("echo \"x\"", 3.4)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1174:'])
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19085
diff changeset
45 endif
9454
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 endfunc
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 func Test_execute_list()
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 call assert_equal("\nsomething\nnice", execute(['echo "something"', 'echo "nice"']))
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 let l = ['for n in range(0, 3)',
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 \ 'echo n',
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 \ 'endfor']
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 call assert_equal("\n0\n1\n2\n3", execute(l))
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 call assert_equal("", execute([]))
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 endfunc
15117
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 9454
diff changeset
57
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 9454
diff changeset
58 func Test_execute_does_not_change_col()
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 9454
diff changeset
59 echo ''
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 9454
diff changeset
60 echon 'abcd'
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 9454
diff changeset
61 let x = execute('silent echo 234343')
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 9454
diff changeset
62 echon 'xyz'
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 9454
diff changeset
63 let text = ''
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 9454
diff changeset
64 for col in range(1, 7)
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 9454
diff changeset
65 let text .= nr2char(screenchar(&lines, col))
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 9454
diff changeset
66 endfor
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 9454
diff changeset
67 call assert_equal('abcdxyz', text)
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 9454
diff changeset
68 endfunc
15121
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
69
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
70 func Test_execute_not_silent()
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
71 echo ''
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
72 echon 'abcd'
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
73 let x = execute('echon 234', '')
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
74 echo 'xyz'
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
75 let text1 = ''
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
76 for col in range(1, 8)
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
77 let text1 .= nr2char(screenchar(&lines - 1, col))
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
78 endfor
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
79 call assert_equal('abcd234 ', text1)
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
80 let text2 = ''
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
81 for col in range(1, 4)
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
82 let text2 .= nr2char(screenchar(&lines, col))
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
83 endfor
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
84 call assert_equal('xyz ', text2)
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
85 endfunc
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
86
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
87 func Test_win_execute()
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
88 let thiswin = win_getid()
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
89 new
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
90 let otherwin = win_getid()
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
91 call setline(1, 'the new window')
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
92 call win_gotoid(thiswin)
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
93 let line = win_execute(otherwin, 'echo getline(1)')
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
94 call assert_match('the new window', line)
23596
9fa72351c18f patch 8.2.2340: win_execute() unexpectedly returns number zero when failing
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
95 let line = win_execute(134343, 'echo getline(1)')
9fa72351c18f patch 8.2.2340: win_execute() unexpectedly returns number zero when failing
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
96 call assert_equal('', line)
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
97
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18259
diff changeset
98 if has('popupwin')
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
99 let popupwin = popup_create('the popup win', {'line': 2, 'col': 3})
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
100 redraw
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17670
diff changeset
101 let line = 'echo getline(1)'->win_execute(popupwin)
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
102 call assert_match('the popup win', line)
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
103
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
104 call popup_close(popupwin)
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
105 endif
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
106
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
107 call win_gotoid(otherwin)
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
108 bwipe!
26121
2c64a420ce7e patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
109
2c64a420ce7e patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
110 " check :lcd in another window does not change directory
2c64a420ce7e patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
111 let curid = win_getid()
2c64a420ce7e patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
112 let curdir = getcwd()
2c64a420ce7e patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
113 split Xother
2c64a420ce7e patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
114 lcd ..
2c64a420ce7e patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
115 " Use :pwd to get the actual current directory
2c64a420ce7e patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
116 let otherdir = execute('pwd')
2c64a420ce7e patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
117 call win_execute(curid, 'lcd testdir')
2c64a420ce7e patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
118 call assert_equal(otherdir, execute('pwd'))
2c64a420ce7e patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
119 bwipe!
2c64a420ce7e patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
120 execute 'cd ' .. curdir
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
121 endfunc
17670
1be29c149103 patch 8.1.1832: win_execute() does not work in other tab
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
122
18259
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
123 func Test_win_execute_update_ruler()
18767
068337e86133 patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
124 CheckFeature quickfix
068337e86133 patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
125
18259
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
126 enew
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
127 call setline(1, range(500))
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
128 20
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
129 split
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
130 let winid = win_getid()
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
131 set ruler
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
132 wincmd w
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
133 let height = winheight(winid)
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
134 redraw
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
135 call assert_match('20,1', Screenline(height + 1))
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
136 let line = win_execute(winid, 'call cursor(100, 1)')
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
137 redraw
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
138 call assert_match('100,1', Screenline(height + 1))
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
139
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
140 bwipe!
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
141 endfunc
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
142
17670
1be29c149103 patch 8.1.1832: win_execute() does not work in other tab
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
143 func Test_win_execute_other_tab()
1be29c149103 patch 8.1.1832: win_execute() does not work in other tab
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
144 let thiswin = win_getid()
1be29c149103 patch 8.1.1832: win_execute() does not work in other tab
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
145 tabnew
1be29c149103 patch 8.1.1832: win_execute() does not work in other tab
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
146 call win_execute(thiswin, 'let xyz = 1')
1be29c149103 patch 8.1.1832: win_execute() does not work in other tab
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
147 call assert_equal(1, xyz)
1be29c149103 patch 8.1.1832: win_execute() does not work in other tab
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
148 tabclose
1be29c149103 patch 8.1.1832: win_execute() does not work in other tab
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
149 unlet xyz
1be29c149103 patch 8.1.1832: win_execute() does not work in other tab
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
150 endfunc
19085
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
151
26978
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26666
diff changeset
152 func Test_win_execute_visual_redraw()
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26666
diff changeset
153 call setline(1, ['a', 'b', 'c'])
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26666
diff changeset
154 new
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26666
diff changeset
155 wincmd p
26994
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
156 " start Visual in current window, redraw in other window with fewer lines
26978
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26666
diff changeset
157 call feedkeys("G\<C-V>", 'txn')
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26666
diff changeset
158 call win_execute(winnr('#')->win_getid(), 'redraw')
26994
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
159 call feedkeys("\<Esc>", 'txn')
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
160 bwipe!
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
161 bwipe!
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
162
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
163 enew
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
164 new
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
165 call setline(1, ['a', 'b', 'c'])
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
166 let winid = win_getid()
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
167 wincmd p
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
168 " start Visual in current window, extend it in other window with more lines
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
169 call feedkeys("\<C-V>", 'txn')
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
170 call win_execute(winid, 'call feedkeys("G\<C-V>", ''txn'')')
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
171 redraw
8d9506f3542e patch 8.2.4026: ml_get error with specific win_execute() command
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
172
26978
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26666
diff changeset
173 bwipe!
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26666
diff changeset
174 bwipe!
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26666
diff changeset
175 endfunc
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26666
diff changeset
176
26666
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
177 func Test_win_execute_on_startup()
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
178 CheckRunVimInTerminal
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
179
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
180 let lines =<< trim END
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
181 vim9script
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
182 [repeat('x', &columns)]->writefile('Xfile1')
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
183 silent tabedit Xfile2
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
184 var id = win_getid()
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
185 silent tabedit Xfile3
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
186 autocmd VimEnter * win_execute(id, 'close')
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
187 END
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
188 call writefile(lines, 'XwinExecute')
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
189 let buf = RunVimInTerminal('-p Xfile1 -Nu XwinExecute', {})
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
190
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
191 " this was crashing on exit with EXITFREE defined
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
192 call StopVimInTerminal(buf)
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
193
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
194 call delete('XwinExecute')
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
195 call delete('Xfile1')
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
196 endfunc
bbcbb3c13fba patch 8.2.3862: crash on exit with EXITFREE and using win_execute()
Bram Moolenaar <Bram@vim.org>
parents: 26650
diff changeset
197
20156
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
198 func Test_execute_func_with_null()
19085
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
199 call assert_equal("", execute(test_null_string()))
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
200 call assert_equal("", execute(test_null_list()))
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
201 call assert_fails('call execute(test_null_dict())', 'E731:')
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
202 call assert_fails('call execute(test_null_blob())', 'E976:')
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
203 call assert_fails('call execute(test_null_partial())','E729:')
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
204 if has('job')
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
205 call assert_fails('call execute(test_null_job())', 'E908:')
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
206 call assert_fails('call execute(test_null_channel())', 'E908:')
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
207 endif
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
208 endfunc
20156
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
209
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
210 " vim: shiftwidth=2 sts=2 expandtab