Mercurial > vim
annotate src/testdir/test_prompt_buffer.vim @ 23554:c43e824fd305
Added tag v8.2.2319 for changeset 5c094273c01565a714ac1acaf674687102850788
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 09 Jan 2021 16:00:05 +0100 |
parents | 3f04c2cf0ced |
children | 13812db714fa |
rev | line source |
---|---|
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for setting 'buftype' to "prompt" |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
17089
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17049
diff
changeset
|
3 source check.vim |
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17049
diff
changeset
|
4 CheckFeature channel |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 source shared.vim |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 source screendump.vim |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
9 func CanTestPromptBuffer() |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 " We need to use a terminal window to be able to feed keys without leaving |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 " Insert mode. |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
20941
diff
changeset
|
12 CheckFeature terminal |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
20941
diff
changeset
|
13 |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
20941
diff
changeset
|
14 " TODO: make the tests work on MS-Windows |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
20941
diff
changeset
|
15 CheckNotMSWindows |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
16 endfunc |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
17 |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
18 func WriteScript(name) |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 call writefile([ |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 \ 'func TextEntered(text)', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 \ ' if a:text == "exit"', |
14149
fba38a3491f5
patch 8.1.0092: prompt buffer test fails
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
22 \ ' " Reset &modified to allow the buffer to be closed.', |
fba38a3491f5
patch 8.1.0092: prompt buffer test fails
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
23 \ ' set nomodified', |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 \ ' stopinsert', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 \ ' close', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 \ ' else', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 \ ' " Add the output above the current prompt.', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 \ ' call append(line("$") - 1, "Command: \"" . a:text . "\"")', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 \ ' " Reset &modified to allow the buffer to be closed.', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 \ ' set nomodified', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 \ ' call timer_start(20, {id -> TimerFunc(a:text)})', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 \ ' endif', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 \ 'endfunc', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 \ '', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 \ 'func TimerFunc(text)', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 \ ' " Add the output above the current prompt.', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 \ ' call append(line("$") - 1, "Result: \"" . a:text . "\"")', |
14025
eb5ee7479d31
patch 8.1.0030: stoping Vim running in a terminal may not work
Christian Brabandt <cb@256bit.org>
parents:
14021
diff
changeset
|
38 \ ' " Reset &modified to allow the buffer to be closed.', |
eb5ee7479d31
patch 8.1.0030: stoping Vim running in a terminal may not work
Christian Brabandt <cb@256bit.org>
parents:
14021
diff
changeset
|
39 \ ' set nomodified', |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 \ 'endfunc', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 \ '', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 \ 'call setline(1, "other buffer")', |
14025
eb5ee7479d31
patch 8.1.0030: stoping Vim running in a terminal may not work
Christian Brabandt <cb@256bit.org>
parents:
14021
diff
changeset
|
43 \ 'set nomodified', |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 \ 'new', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 \ 'set buftype=prompt', |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 \ 'call prompt_setcallback(bufnr(""), function("TextEntered"))', |
17976
6d11a0d5751d
patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
47 \ 'eval bufnr("")->prompt_setprompt("cmd: ")', |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 \ 'startinsert', |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
49 \ ], a:name) |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
50 endfunc |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
51 |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
52 func Test_prompt_basic() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
20941
diff
changeset
|
53 call CanTestPromptBuffer() |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
54 let scriptName = 'XpromptscriptBasic' |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
55 call WriteScript(scriptName) |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
56 |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
57 let buf = RunVimInTerminal('-S ' . scriptName, {}) |
17976
6d11a0d5751d
patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
58 call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))}) |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 call term_sendkeys(buf, "hello\<CR>") |
17976
6d11a0d5751d
patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
61 call WaitForAssert({-> assert_equal('cmd: hello', term_getline(buf, 1))}) |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 call WaitForAssert({-> assert_equal('Command: "hello"', term_getline(buf, 2))}) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 call WaitForAssert({-> assert_equal('Result: "hello"', term_getline(buf, 3))}) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 call term_sendkeys(buf, "exit\<CR>") |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))}) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 call StopVimInTerminal(buf) |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
69 call delete(scriptName) |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 endfunc |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
71 |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
72 func Test_prompt_editing() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
20941
diff
changeset
|
73 call CanTestPromptBuffer() |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
74 let scriptName = 'XpromptscriptEditing' |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
75 call WriteScript(scriptName) |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
76 |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
77 let buf = RunVimInTerminal('-S ' . scriptName, {}) |
17976
6d11a0d5751d
patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
78 call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))}) |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
79 |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
80 let bs = "\<BS>" |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
81 call term_sendkeys(buf, "hello" . bs . bs) |
17976
6d11a0d5751d
patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
82 call WaitForAssert({-> assert_equal('cmd: hel', term_getline(buf, 1))}) |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
83 |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
84 let left = "\<Left>" |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
85 call term_sendkeys(buf, left . left . left . bs . '-') |
17976
6d11a0d5751d
patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
86 call WaitForAssert({-> assert_equal('cmd: -hel', term_getline(buf, 1))}) |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
87 |
22934
3f04c2cf0ced
patch 8.2.2014: using CTRL-O in a prompt buffer moves cursor to start
Bram Moolenaar <Bram@vim.org>
parents:
22858
diff
changeset
|
88 call term_sendkeys(buf, "\<C-O>lz") |
3f04c2cf0ced
patch 8.2.2014: using CTRL-O in a prompt buffer moves cursor to start
Bram Moolenaar <Bram@vim.org>
parents:
22858
diff
changeset
|
89 call WaitForAssert({-> assert_equal('cmd: -hzel', term_getline(buf, 1))}) |
3f04c2cf0ced
patch 8.2.2014: using CTRL-O in a prompt buffer moves cursor to start
Bram Moolenaar <Bram@vim.org>
parents:
22858
diff
changeset
|
90 |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
91 let end = "\<End>" |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
92 call term_sendkeys(buf, end . "x") |
22934
3f04c2cf0ced
patch 8.2.2014: using CTRL-O in a prompt buffer moves cursor to start
Bram Moolenaar <Bram@vim.org>
parents:
22858
diff
changeset
|
93 call WaitForAssert({-> assert_equal('cmd: -hzelx', term_getline(buf, 1))}) |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
94 |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
95 call term_sendkeys(buf, "\<C-U>exit\<CR>") |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
96 call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))}) |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
97 |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
98 call StopVimInTerminal(buf) |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
99 call delete(scriptName) |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14025
diff
changeset
|
100 endfunc |
17151
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
101 |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
102 func Test_prompt_garbage_collect() |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
103 func MyPromptCallback(x, text) |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
104 " NOP |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
105 endfunc |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
106 func MyPromptInterrupt(x) |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
107 " NOP |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
108 endfunc |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
109 |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
110 new |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
111 set buftype=prompt |
17976
6d11a0d5751d
patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
112 eval bufnr('')->prompt_setcallback(function('MyPromptCallback', [{}])) |
6d11a0d5751d
patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
113 eval bufnr('')->prompt_setinterrupt(function('MyPromptInterrupt', [{}])) |
17151
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
114 call test_garbagecollect_now() |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
115 " Must not crash |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
116 call feedkeys("\<CR>\<C-C>", 'xt') |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
117 call assert_true(v:true) |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
118 |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
119 call assert_fails("call prompt_setcallback(bufnr(), [])", 'E921:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
120 call assert_equal(0, prompt_setcallback({}, '')) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
121 call assert_fails("call prompt_setinterrupt(bufnr(), [])", 'E921:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
122 call assert_equal(0, prompt_setinterrupt({}, '')) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19625
diff
changeset
|
123 |
17151
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
124 delfunc MyPromptCallback |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
125 bwipe! |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
126 endfunc |
19613
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
17976
diff
changeset
|
127 |
22858
52b5aa2e8c8f
patch 8.2.1976: cannot backspace in prompt buffer after using cursor-left
Bram Moolenaar <Bram@vim.org>
parents:
22466
diff
changeset
|
128 func Test_prompt_backspace() |
52b5aa2e8c8f
patch 8.2.1976: cannot backspace in prompt buffer after using cursor-left
Bram Moolenaar <Bram@vim.org>
parents:
22466
diff
changeset
|
129 new |
52b5aa2e8c8f
patch 8.2.1976: cannot backspace in prompt buffer after using cursor-left
Bram Moolenaar <Bram@vim.org>
parents:
22466
diff
changeset
|
130 set buftype=prompt |
52b5aa2e8c8f
patch 8.2.1976: cannot backspace in prompt buffer after using cursor-left
Bram Moolenaar <Bram@vim.org>
parents:
22466
diff
changeset
|
131 call feedkeys("A123456\<Left>\<BS>\<Esc>", 'xt') |
52b5aa2e8c8f
patch 8.2.1976: cannot backspace in prompt buffer after using cursor-left
Bram Moolenaar <Bram@vim.org>
parents:
22466
diff
changeset
|
132 call assert_equal('% 12346', getline(1)) |
52b5aa2e8c8f
patch 8.2.1976: cannot backspace in prompt buffer after using cursor-left
Bram Moolenaar <Bram@vim.org>
parents:
22466
diff
changeset
|
133 bwipe! |
52b5aa2e8c8f
patch 8.2.1976: cannot backspace in prompt buffer after using cursor-left
Bram Moolenaar <Bram@vim.org>
parents:
22466
diff
changeset
|
134 endfunc |
52b5aa2e8c8f
patch 8.2.1976: cannot backspace in prompt buffer after using cursor-left
Bram Moolenaar <Bram@vim.org>
parents:
22466
diff
changeset
|
135 |
19613
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
17976
diff
changeset
|
136 " Test for editing the prompt buffer |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
17976
diff
changeset
|
137 func Test_prompt_buffer_edit() |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
17976
diff
changeset
|
138 new |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
17976
diff
changeset
|
139 set buftype=prompt |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
17976
diff
changeset
|
140 normal! i |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
17976
diff
changeset
|
141 call assert_beeps('normal! dd') |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
17976
diff
changeset
|
142 call assert_beeps('normal! ~') |
19625
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19613
diff
changeset
|
143 call assert_beeps('normal! o') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19613
diff
changeset
|
144 call assert_beeps('normal! O') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19613
diff
changeset
|
145 call assert_beeps('normal! p') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19613
diff
changeset
|
146 call assert_beeps('normal! P') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19613
diff
changeset
|
147 call assert_beeps('normal! u') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19613
diff
changeset
|
148 call assert_beeps('normal! ra') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19613
diff
changeset
|
149 call assert_beeps('normal! s') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19613
diff
changeset
|
150 call assert_beeps('normal! S') |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19613
diff
changeset
|
151 call assert_beeps("normal! \<C-A>") |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19613
diff
changeset
|
152 call assert_beeps("normal! \<C-X>") |
20941
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
20120
diff
changeset
|
153 " pressing CTRL-W in the prompt buffer should trigger the window commands |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
20120
diff
changeset
|
154 call assert_equal(1, winnr()) |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
20120
diff
changeset
|
155 exe "normal A\<C-W>\<C-W>" |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
20120
diff
changeset
|
156 call assert_equal(2, winnr()) |
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
20120
diff
changeset
|
157 wincmd w |
19613
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
17976
diff
changeset
|
158 close! |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
159 call assert_equal(0, prompt_setprompt([], '')) |
19613
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
17976
diff
changeset
|
160 endfunc |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
17976
diff
changeset
|
161 |
22077
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
162 func Test_prompt_buffer_getbufinfo() |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
163 new |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
164 call assert_equal('', prompt_getprompt('%')) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
165 call assert_equal('', prompt_getprompt(bufnr('%'))) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
166 let another_buffer = bufnr('%') |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
167 |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
168 set buftype=prompt |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
169 call assert_equal('% ', prompt_getprompt('%')) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
170 call prompt_setprompt( bufnr( '%' ), 'This is a test: ' ) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
171 call assert_equal('This is a test: ', prompt_getprompt('%')) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
172 |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
173 call prompt_setprompt( bufnr( '%' ), '' ) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
174 call assert_equal('', '%'->prompt_getprompt()) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
175 |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
176 call prompt_setprompt( bufnr( '%' ), 'Another: ' ) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
177 call assert_equal('Another: ', prompt_getprompt('%')) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
178 let another = bufnr('%') |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
179 |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
180 new |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
181 |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
182 call assert_equal('', prompt_getprompt('%')) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
183 call assert_equal('Another: ', prompt_getprompt(another)) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
184 |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
185 " Doesn't exist |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
186 let buffers_before = len( getbufinfo() ) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
187 call assert_equal('', prompt_getprompt( bufnr('$') + 1)) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
188 call assert_equal(buffers_before, len( getbufinfo())) |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
189 |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
190 " invalid type |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
191 call assert_fails('call prompt_getprompt({})', 'E728:') |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
192 |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
193 %bwipe! |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
194 endfunc |
335365fcbb60
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
195 |
22466
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
196 function! Test_prompt_while_writing_to_hidden_buffer() |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
197 call CanTestPromptBuffer() |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
198 CheckUnix |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
199 |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
200 " Make a job continuously write to a hidden buffer, check that the prompt |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
201 " buffer is not affected. |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
202 let scriptName = 'XpromptscriptHiddenBuf' |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
203 let script =<< trim END |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
204 set buftype=prompt |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
205 call prompt_setprompt( bufnr(), 'cmd:' ) |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
206 let job = job_start(['/bin/sh', '-c', |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
207 \ 'while true; |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
208 \ do echo line; |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
209 \ sleep 0.1; |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
210 \ done'], #{out_io: 'buffer', out_name: ''}) |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
211 startinsert |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
212 END |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
213 eval script->writefile(scriptName) |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
214 |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
215 let buf = RunVimInTerminal('-S ' .. scriptName, {}) |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
216 call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))}) |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
217 |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
218 call term_sendkeys(buf, 'test') |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
219 call WaitForAssert({-> assert_equal('cmd:test', term_getline(buf, 1))}) |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
220 call term_sendkeys(buf, 'test') |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
221 call WaitForAssert({-> assert_equal('cmd:testtest', term_getline(buf, 1))}) |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
222 call term_sendkeys(buf, 'test') |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
223 call WaitForAssert({-> assert_equal('cmd:testtesttest', term_getline(buf, 1))}) |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
224 |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
225 call StopVimInTerminal(buf) |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
226 call delete(scriptName) |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
227 endfunc |
18f400b24f5f
patch 8.2.1781: writing to prompt buffer interferes with insert mode
Bram Moolenaar <Bram@vim.org>
parents:
22077
diff
changeset
|
228 |
19613
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
17976
diff
changeset
|
229 " vim: shiftwidth=2 sts=2 expandtab |