Bram Moolenaar | 461a7fc | 2018-12-22 13:28:07 +0100 | [diff] [blame] | 1 | " Tests for :messages, :echomsg, :echoerr |
Bram Moolenaar | 451f849 | 2016-04-14 17:16:22 +0200 | [diff] [blame] | 2 | |
Bram Moolenaar | 494e906 | 2020-05-31 21:28:02 +0200 | [diff] [blame] | 3 | source check.vim |
Bram Moolenaar | abc7c7f | 2019-04-20 15:10:13 +0200 | [diff] [blame] | 4 | source shared.vim |
Bram Moolenaar | c6d539b | 2019-12-28 17:10:46 +0100 | [diff] [blame] | 5 | source term_util.vim |
Bram Moolenaar | b42c0d5 | 2020-05-29 22:41:41 +0200 | [diff] [blame] | 6 | source view_util.vim |
Bram Moolenaar | 3d30af8 | 2020-10-13 22:15:56 +0200 | [diff] [blame] | 7 | source screendump.vim |
Bram Moolenaar | abc7c7f | 2019-04-20 15:10:13 +0200 | [diff] [blame] | 8 | |
Bram Moolenaar | 49b2fb3 | 2020-04-25 17:13:56 +0200 | [diff] [blame] | 9 | func Test_messages() |
Bram Moolenaar | 451f849 | 2016-04-14 17:16:22 +0200 | [diff] [blame] | 10 | let oldmore = &more |
| 11 | try |
| 12 | set nomore |
| 13 | |
| 14 | let arr = map(range(10), '"hello" . v:val') |
| 15 | for s in arr |
| 16 | echomsg s | redraw |
| 17 | endfor |
Bram Moolenaar | 451f849 | 2016-04-14 17:16:22 +0200 | [diff] [blame] | 18 | |
Bram Moolenaar | bea1ede | 2016-04-14 19:44:36 +0200 | [diff] [blame] | 19 | " get last two messages |
Bram Moolenaar | 451f849 | 2016-04-14 17:16:22 +0200 | [diff] [blame] | 20 | redir => result |
| 21 | 2messages | redraw |
| 22 | redir END |
Bram Moolenaar | bea1ede | 2016-04-14 19:44:36 +0200 | [diff] [blame] | 23 | let msg_list = split(result, "\n") |
| 24 | call assert_equal(["hello8", "hello9"], msg_list) |
Bram Moolenaar | 451f849 | 2016-04-14 17:16:22 +0200 | [diff] [blame] | 25 | |
| 26 | " clear messages without last one |
| 27 | 1messages clear |
Bram Moolenaar | 49b2fb3 | 2020-04-25 17:13:56 +0200 | [diff] [blame] | 28 | let msg_list = GetMessages() |
Bram Moolenaar | bea1ede | 2016-04-14 19:44:36 +0200 | [diff] [blame] | 29 | call assert_equal(['hello9'], msg_list) |
Bram Moolenaar | 451f849 | 2016-04-14 17:16:22 +0200 | [diff] [blame] | 30 | |
| 31 | " clear all messages |
| 32 | messages clear |
Bram Moolenaar | 49b2fb3 | 2020-04-25 17:13:56 +0200 | [diff] [blame] | 33 | let msg_list = GetMessages() |
| 34 | call assert_equal([], msg_list) |
Bram Moolenaar | 451f849 | 2016-04-14 17:16:22 +0200 | [diff] [blame] | 35 | finally |
| 36 | let &more = oldmore |
| 37 | endtry |
Bram Moolenaar | 067297e | 2020-04-13 19:55:50 +0200 | [diff] [blame] | 38 | |
| 39 | call assert_fails('message 1', 'E474:') |
Bram Moolenaar | 49b2fb3 | 2020-04-25 17:13:56 +0200 | [diff] [blame] | 40 | endfunc |
Bram Moolenaar | 2abad54 | 2018-05-19 14:43:45 +0200 | [diff] [blame] | 41 | |
Bram Moolenaar | f52f9ea | 2018-06-27 20:49:44 +0200 | [diff] [blame] | 42 | " Patch 7.4.1696 defined the "clearmode()" function for clearing the mode |
Bram Moolenaar | 2abad54 | 2018-05-19 14:43:45 +0200 | [diff] [blame] | 43 | " indicator (e.g., "-- INSERT --") when ":stopinsert" is invoked. Message |
| 44 | " output could then be disturbed when 'cmdheight' was greater than one. |
| 45 | " This test ensures that the bugfix for this issue remains in place. |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 46 | func Test_stopinsert_does_not_break_message_output() |
Bram Moolenaar | 2abad54 | 2018-05-19 14:43:45 +0200 | [diff] [blame] | 47 | set cmdheight=2 |
| 48 | redraw! |
| 49 | |
| 50 | stopinsert | echo 'test echo' |
| 51 | call assert_equal(116, screenchar(&lines - 1, 1)) |
| 52 | call assert_equal(32, screenchar(&lines, 1)) |
| 53 | redraw! |
| 54 | |
| 55 | stopinsert | echomsg 'test echomsg' |
| 56 | call assert_equal(116, screenchar(&lines - 1, 1)) |
| 57 | call assert_equal(32, screenchar(&lines, 1)) |
| 58 | redraw! |
| 59 | |
| 60 | set cmdheight& |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 61 | endfunc |
Bram Moolenaar | b513d30 | 2018-12-02 14:55:08 +0100 | [diff] [blame] | 62 | |
| 63 | func Test_message_completion() |
| 64 | call feedkeys(":message \<C-A>\<C-B>\"\<CR>", 'tx') |
| 65 | call assert_equal('"message clear', @:) |
| 66 | endfunc |
Bram Moolenaar | 461a7fc | 2018-12-22 13:28:07 +0100 | [diff] [blame] | 67 | |
| 68 | func Test_echomsg() |
| 69 | call assert_equal("\nhello", execute(':echomsg "hello"')) |
| 70 | call assert_equal("\n", execute(':echomsg ""')) |
| 71 | call assert_equal("\n12345", execute(':echomsg 12345')) |
| 72 | call assert_equal("\n[]", execute(':echomsg []')) |
| 73 | call assert_equal("\n[1, 2, 3]", execute(':echomsg [1, 2, 3]')) |
Bram Moolenaar | db950e4 | 2020-04-22 19:13:19 +0200 | [diff] [blame] | 74 | call assert_equal("\n[1, 2, []]", execute(':echomsg [1, 2, test_null_list()]')) |
Bram Moolenaar | 461a7fc | 2018-12-22 13:28:07 +0100 | [diff] [blame] | 75 | call assert_equal("\n{}", execute(':echomsg {}')) |
| 76 | call assert_equal("\n{'a': 1, 'b': 2}", execute(':echomsg {"a": 1, "b": 2}')) |
Bram Moolenaar | 73e28dc | 2022-09-17 21:08:33 +0100 | [diff] [blame] | 77 | call assert_equal("\n1.23", execute(':echomsg 1.23')) |
Bram Moolenaar | 461a7fc | 2018-12-22 13:28:07 +0100 | [diff] [blame] | 78 | call assert_match("function('<lambda>\\d*')", execute(':echomsg {-> 1234}')) |
| 79 | endfunc |
| 80 | |
| 81 | func Test_echoerr() |
| 82 | call test_ignore_error('IgNoRe') |
| 83 | call assert_equal("\nIgNoRe hello", execute(':echoerr "IgNoRe hello"')) |
| 84 | call assert_equal("\n12345 IgNoRe", execute(':echoerr 12345 "IgNoRe"')) |
| 85 | call assert_equal("\n[1, 2, 'IgNoRe']", execute(':echoerr [1, 2, "IgNoRe"]')) |
| 86 | call assert_equal("\n{'IgNoRe': 2, 'a': 1}", execute(':echoerr {"a": 1, "IgNoRe": 2}')) |
Bram Moolenaar | 73e28dc | 2022-09-17 21:08:33 +0100 | [diff] [blame] | 87 | call assert_equal("\n1.23 IgNoRe", execute(':echoerr 1.23 "IgNoRe"')) |
Bram Moolenaar | ce90e36 | 2019-09-08 18:58:44 +0200 | [diff] [blame] | 88 | eval '<lambda>'->test_ignore_error() |
Bram Moolenaar | 461a7fc | 2018-12-22 13:28:07 +0100 | [diff] [blame] | 89 | call assert_match("function('<lambda>\\d*')", execute(':echoerr {-> 1234}')) |
| 90 | call test_ignore_error('RESET') |
| 91 | endfunc |
Bram Moolenaar | abc7c7f | 2019-04-20 15:10:13 +0200 | [diff] [blame] | 92 | |
| 93 | func Test_mode_message_at_leaving_insert_by_ctrl_c() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 94 | CheckFeature terminal |
| 95 | CheckNotGui |
Bram Moolenaar | abc7c7f | 2019-04-20 15:10:13 +0200 | [diff] [blame] | 96 | |
| 97 | " Set custom statusline built by user-defined function. |
| 98 | let testfile = 'Xtest.vim' |
Bram Moolenaar | e7eb927 | 2019-06-24 00:58:07 +0200 | [diff] [blame] | 99 | let lines =<< trim END |
| 100 | func StatusLine() abort |
| 101 | return "" |
| 102 | endfunc |
| 103 | set statusline=%!StatusLine() |
| 104 | set laststatus=2 |
| 105 | END |
Bram Moolenaar | b152b6a | 2022-09-29 21:37:33 +0100 | [diff] [blame] | 106 | call writefile(lines, testfile, 'D') |
Bram Moolenaar | abc7c7f | 2019-04-20 15:10:13 +0200 | [diff] [blame] | 107 | |
| 108 | let rows = 10 |
| 109 | let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows}) |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 110 | call TermWait(buf, 100) |
Bram Moolenaar | abc7c7f | 2019-04-20 15:10:13 +0200 | [diff] [blame] | 111 | call assert_equal('run', job_status(term_getjob(buf))) |
| 112 | |
| 113 | call term_sendkeys(buf, "i") |
| 114 | call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))}) |
| 115 | call term_sendkeys(buf, "\<C-C>") |
| 116 | call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))}) |
| 117 | |
| 118 | call term_sendkeys(buf, ":qall!\<CR>") |
| 119 | call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))}) |
Bram Moolenaar | b152b6a | 2022-09-29 21:37:33 +0100 | [diff] [blame] | 120 | |
Bram Moolenaar | abc7c7f | 2019-04-20 15:10:13 +0200 | [diff] [blame] | 121 | exe buf . 'bwipe!' |
Bram Moolenaar | abc7c7f | 2019-04-20 15:10:13 +0200 | [diff] [blame] | 122 | endfunc |
Bram Moolenaar | 4c25bd7 | 2019-04-20 23:38:07 +0200 | [diff] [blame] | 123 | |
| 124 | func Test_mode_message_at_leaving_insert_with_esc_mapped() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 125 | CheckFeature terminal |
| 126 | CheckNotGui |
Bram Moolenaar | 4c25bd7 | 2019-04-20 23:38:07 +0200 | [diff] [blame] | 127 | |
| 128 | " Set custom statusline built by user-defined function. |
| 129 | let testfile = 'Xtest.vim' |
Bram Moolenaar | e7eb927 | 2019-06-24 00:58:07 +0200 | [diff] [blame] | 130 | let lines =<< trim END |
| 131 | set laststatus=2 |
| 132 | inoremap <Esc> <Esc>00 |
| 133 | END |
Bram Moolenaar | b152b6a | 2022-09-29 21:37:33 +0100 | [diff] [blame] | 134 | call writefile(lines, testfile, 'D') |
Bram Moolenaar | 4c25bd7 | 2019-04-20 23:38:07 +0200 | [diff] [blame] | 135 | |
| 136 | let rows = 10 |
| 137 | let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows}) |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 138 | call WaitForAssert({-> assert_match('0,0-1\s*All$', term_getline(buf, rows - 1))}) |
Bram Moolenaar | 4c25bd7 | 2019-04-20 23:38:07 +0200 | [diff] [blame] | 139 | call assert_equal('run', job_status(term_getjob(buf))) |
| 140 | |
| 141 | call term_sendkeys(buf, "i") |
| 142 | call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))}) |
| 143 | call term_sendkeys(buf, "\<Esc>") |
| 144 | call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))}) |
| 145 | |
| 146 | call term_sendkeys(buf, ":qall!\<CR>") |
| 147 | call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))}) |
Bram Moolenaar | b152b6a | 2022-09-29 21:37:33 +0100 | [diff] [blame] | 148 | |
Bram Moolenaar | 4c25bd7 | 2019-04-20 23:38:07 +0200 | [diff] [blame] | 149 | exe buf . 'bwipe!' |
Bram Moolenaar | 4c25bd7 | 2019-04-20 23:38:07 +0200 | [diff] [blame] | 150 | endfunc |
Bram Moolenaar | 37f4cbd | 2019-08-23 20:58:45 +0200 | [diff] [blame] | 151 | |
| 152 | func Test_echospace() |
| 153 | set noruler noshowcmd laststatus=1 |
| 154 | call assert_equal(&columns - 1, v:echospace) |
| 155 | split |
| 156 | call assert_equal(&columns - 1, v:echospace) |
| 157 | set ruler |
| 158 | call assert_equal(&columns - 1, v:echospace) |
| 159 | close |
| 160 | call assert_equal(&columns - 19, v:echospace) |
| 161 | set showcmd noruler |
| 162 | call assert_equal(&columns - 12, v:echospace) |
| 163 | set showcmd ruler |
| 164 | call assert_equal(&columns - 29, v:echospace) |
Sam-programs | 062141b | 2024-02-29 17:40:29 +0100 | [diff] [blame] | 165 | set showcmdloc=statusline |
| 166 | call assert_equal(&columns - 19, v:echospace) |
| 167 | set showcmdloc=tabline |
| 168 | call assert_equal(&columns - 19, v:echospace) |
zeertzjq | c27fcf4 | 2024-03-01 23:01:43 +0100 | [diff] [blame] | 169 | call assert_fails('set showcmdloc=leap', 'E474:') |
| 170 | call assert_equal(&columns - 19, v:echospace) |
| 171 | set showcmdloc=last |
| 172 | call assert_equal(&columns - 29, v:echospace) |
| 173 | call assert_fails('set showcmdloc=jump', 'E474:') |
| 174 | call assert_equal(&columns - 29, v:echospace) |
Bram Moolenaar | 37f4cbd | 2019-08-23 20:58:45 +0200 | [diff] [blame] | 175 | |
Sam-programs | 062141b | 2024-02-29 17:40:29 +0100 | [diff] [blame] | 176 | set ruler& showcmd& showcmdloc& |
Bram Moolenaar | 37f4cbd | 2019-08-23 20:58:45 +0200 | [diff] [blame] | 177 | endfunc |
Bram Moolenaar | c6d539b | 2019-12-28 17:10:46 +0100 | [diff] [blame] | 178 | |
zeertzjq | bdedd2b | 2022-09-20 12:45:15 +0100 | [diff] [blame] | 179 | func Test_warning_scroll() |
| 180 | CheckRunVimInTerminal |
| 181 | let lines =<< trim END |
| 182 | call test_override('ui_delay', 50) |
| 183 | set noruler |
| 184 | set readonly |
| 185 | undo |
| 186 | END |
| 187 | call writefile(lines, 'XTestWarningScroll', 'D') |
| 188 | let buf = RunVimInTerminal('', #{rows: 8}) |
| 189 | |
| 190 | " When the warning comes from a script, messages are scrolled so that the |
| 191 | " stacktrace is visible. |
| 192 | call term_sendkeys(buf, ":source XTestWarningScroll\n") |
| 193 | " only match the final colon in the line that shows the source |
| 194 | call WaitForAssert({-> assert_match(':$', term_getline(buf, 5))}) |
| 195 | call WaitForAssert({-> assert_equal('line 4:W10: Warning: Changing a readonly file', term_getline(buf, 6))}) |
| 196 | call WaitForAssert({-> assert_equal('Already at oldest change', term_getline(buf, 7))}) |
| 197 | call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 8))}) |
| 198 | call term_sendkeys(buf, "\n") |
| 199 | |
| 200 | " When the warning does not come from a script, messages are not scrolled. |
| 201 | call term_sendkeys(buf, ":enew\n") |
| 202 | call term_sendkeys(buf, ":set readonly\n") |
| 203 | call term_sendkeys(buf, 'u') |
| 204 | call WaitForAssert({-> assert_equal('W10: Warning: Changing a readonly file', term_getline(buf, 8))}) |
| 205 | call WaitForAssert({-> assert_equal('Already at oldest change', term_getline(buf, 8))}) |
| 206 | |
| 207 | " clean up |
| 208 | call StopVimInTerminal(buf) |
| 209 | endfunc |
| 210 | |
Bram Moolenaar | c6d539b | 2019-12-28 17:10:46 +0100 | [diff] [blame] | 211 | " Test more-prompt (see :help more-prompt). |
| 212 | func Test_message_more() |
Bram Moolenaar | 494e906 | 2020-05-31 21:28:02 +0200 | [diff] [blame] | 213 | CheckRunVimInTerminal |
Christian Brabandt | 51d4d84 | 2024-12-06 17:26:25 +0100 | [diff] [blame] | 214 | |
Bram Moolenaar | c6d539b | 2019-12-28 17:10:46 +0100 | [diff] [blame] | 215 | let buf = RunVimInTerminal('', {'rows': 6}) |
| 216 | call term_sendkeys(buf, ":call setline(1, range(1, 100))\n") |
| 217 | |
zeertzjq | 46af7bc | 2022-07-28 12:34:09 +0100 | [diff] [blame] | 218 | call term_sendkeys(buf, ":%pfoo\<C-H>\<C-H>\<C-H>#") |
| 219 | call WaitForAssert({-> assert_equal(':%p#', term_getline(buf, 6))}) |
| 220 | call term_sendkeys(buf, "\n") |
Bram Moolenaar | c6d539b | 2019-12-28 17:10:46 +0100 | [diff] [blame] | 221 | call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))}) |
| 222 | call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) |
| 223 | |
| 224 | call term_sendkeys(buf, '?') |
| 225 | call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))}) |
| 226 | call WaitForAssert({-> assert_equal('-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit ', term_getline(buf, 6))}) |
| 227 | |
| 228 | " Down a line with j, <CR>, <NL> or <Down>. |
| 229 | call term_sendkeys(buf, "j") |
| 230 | call WaitForAssert({-> assert_equal(' 6 6', term_getline(buf, 5))}) |
| 231 | call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) |
| 232 | call term_sendkeys(buf, "\<NL>") |
| 233 | call WaitForAssert({-> assert_equal(' 7 7', term_getline(buf, 5))}) |
| 234 | call term_sendkeys(buf, "\<CR>") |
| 235 | call WaitForAssert({-> assert_equal(' 8 8', term_getline(buf, 5))}) |
| 236 | call term_sendkeys(buf, "\<Down>") |
| 237 | call WaitForAssert({-> assert_equal(' 9 9', term_getline(buf, 5))}) |
| 238 | |
| 239 | " Down a screen with <Space>, f, or <PageDown>. |
| 240 | call term_sendkeys(buf, 'f') |
| 241 | call WaitForAssert({-> assert_equal(' 14 14', term_getline(buf, 5))}) |
| 242 | call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) |
| 243 | call term_sendkeys(buf, ' ') |
| 244 | call WaitForAssert({-> assert_equal(' 19 19', term_getline(buf, 5))}) |
| 245 | call term_sendkeys(buf, "\<PageDown>") |
| 246 | call WaitForAssert({-> assert_equal(' 24 24', term_getline(buf, 5))}) |
| 247 | |
| 248 | " Down a page (half a screen) with d. |
| 249 | call term_sendkeys(buf, 'd') |
| 250 | call WaitForAssert({-> assert_equal(' 27 27', term_getline(buf, 5))}) |
| 251 | |
| 252 | " Down all the way with 'G'. |
| 253 | call term_sendkeys(buf, 'G') |
| 254 | call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) |
| 255 | call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) |
| 256 | |
| 257 | " Up a line k, <BS> or <Up>. |
| 258 | call term_sendkeys(buf, 'k') |
| 259 | call WaitForAssert({-> assert_equal(' 99 99', term_getline(buf, 5))}) |
| 260 | call term_sendkeys(buf, "\<BS>") |
| 261 | call WaitForAssert({-> assert_equal(' 98 98', term_getline(buf, 5))}) |
| 262 | call term_sendkeys(buf, "\<Up>") |
| 263 | call WaitForAssert({-> assert_equal(' 97 97', term_getline(buf, 5))}) |
| 264 | |
| 265 | " Up a screen with b or <PageUp>. |
| 266 | call term_sendkeys(buf, 'b') |
| 267 | call WaitForAssert({-> assert_equal(' 92 92', term_getline(buf, 5))}) |
| 268 | call term_sendkeys(buf, "\<PageUp>") |
| 269 | call WaitForAssert({-> assert_equal(' 87 87', term_getline(buf, 5))}) |
| 270 | |
| 271 | " Up a page (half a screen) with u. |
| 272 | call term_sendkeys(buf, 'u') |
| 273 | call WaitForAssert({-> assert_equal(' 84 84', term_getline(buf, 5))}) |
| 274 | |
| 275 | " Up all the way with 'g'. |
| 276 | call term_sendkeys(buf, 'g') |
zeertzjq | ecdc82e | 2022-07-25 19:50:57 +0100 | [diff] [blame] | 277 | call WaitForAssert({-> assert_equal(' 4 4', term_getline(buf, 5))}) |
| 278 | call WaitForAssert({-> assert_equal(':%p#', term_getline(buf, 1))}) |
Bram Moolenaar | c6d539b | 2019-12-28 17:10:46 +0100 | [diff] [blame] | 279 | call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) |
| 280 | |
| 281 | " All the way down. Pressing f should do nothing but pressing |
| 282 | " space should end the more prompt. |
| 283 | call term_sendkeys(buf, 'G') |
| 284 | call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) |
| 285 | call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) |
| 286 | call term_sendkeys(buf, 'f') |
| 287 | call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) |
| 288 | call term_sendkeys(buf, ' ') |
| 289 | call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))}) |
| 290 | |
| 291 | " Pressing g< shows the previous command output. |
| 292 | call term_sendkeys(buf, 'g<') |
| 293 | call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) |
| 294 | call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) |
| 295 | |
zeertzjq | 46af7bc | 2022-07-28 12:34:09 +0100 | [diff] [blame] | 296 | " A command line that doesn't print text is appended to scrollback, |
| 297 | " even if it invokes a nested command line. |
| 298 | call term_sendkeys(buf, ":\<C-R>=':'\<CR>:\<CR>g<") |
| 299 | call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 4))}) |
| 300 | call WaitForAssert({-> assert_equal(':::', term_getline(buf, 5))}) |
| 301 | call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) |
| 302 | |
Bram Moolenaar | c6d539b | 2019-12-28 17:10:46 +0100 | [diff] [blame] | 303 | call term_sendkeys(buf, ":%p#\n") |
| 304 | call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))}) |
| 305 | call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) |
| 306 | |
| 307 | " Stop command output with q, <Esc> or CTRL-C. |
| 308 | call term_sendkeys(buf, 'q') |
| 309 | call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))}) |
| 310 | |
Bram Moolenaar | f4fcedc | 2021-03-15 18:36:20 +0100 | [diff] [blame] | 311 | " Execute a : command from the more prompt |
| 312 | call term_sendkeys(buf, ":%p#\n") |
| 313 | call term_wait(buf) |
| 314 | call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) |
| 315 | call term_sendkeys(buf, ":") |
| 316 | call term_wait(buf) |
| 317 | call WaitForAssert({-> assert_equal(':', term_getline(buf, 6))}) |
| 318 | call term_sendkeys(buf, "echo 'Hello'\n") |
| 319 | call term_wait(buf) |
| 320 | call WaitForAssert({-> assert_equal('Hello ', term_getline(buf, 5))}) |
| 321 | |
Bram Moolenaar | 43c60ed | 2020-02-02 15:55:19 +0100 | [diff] [blame] | 322 | call StopVimInTerminal(buf) |
| 323 | endfunc |
| 324 | |
Bram Moolenaar | 838b746 | 2022-09-26 15:19:56 +0100 | [diff] [blame] | 325 | " Test more-prompt scrollback |
| 326 | func Test_message_more_scrollback() |
| 327 | CheckRunVimInTerminal |
| 328 | |
| 329 | let lines =<< trim END |
| 330 | set t_ut= |
| 331 | hi Normal ctermfg=15 ctermbg=0 |
| 332 | for i in range(100) |
| 333 | echo i |
| 334 | endfor |
| 335 | END |
| 336 | call writefile(lines, 'XmoreScrollback', 'D') |
| 337 | let buf = RunVimInTerminal('-S XmoreScrollback', {'rows': 10}) |
| 338 | call VerifyScreenDump(buf, 'Test_more_scrollback_1', {}) |
| 339 | |
| 340 | call term_sendkeys(buf, 'f') |
| 341 | call TermWait(buf) |
| 342 | call term_sendkeys(buf, 'b') |
| 343 | call VerifyScreenDump(buf, 'Test_more_scrollback_2', {}) |
| 344 | |
| 345 | call term_sendkeys(buf, 'q') |
| 346 | call TermWait(buf) |
| 347 | call StopVimInTerminal(buf) |
| 348 | endfunc |
| 349 | |
Bram Moolenaar | 800cdbb | 2023-06-15 16:40:02 +0100 | [diff] [blame] | 350 | func Test_message_not_cleared_after_mode() |
| 351 | CheckRunVimInTerminal |
| 352 | |
| 353 | let lines =<< trim END |
| 354 | nmap <silent> gx :call DebugSilent('normal')<CR> |
| 355 | vmap <silent> gx :call DebugSilent('visual')<CR> |
| 356 | function DebugSilent(arg) |
| 357 | echomsg "from DebugSilent" a:arg |
| 358 | endfunction |
| 359 | set showmode |
| 360 | set cmdheight=1 |
Bram Moolenaar | da51ad5 | 2023-06-15 18:44:50 +0100 | [diff] [blame] | 361 | call test_settime(1) |
| 362 | call setline(1, ['one', 'NoSuchFile', 'three']) |
Bram Moolenaar | 800cdbb | 2023-06-15 16:40:02 +0100 | [diff] [blame] | 363 | END |
| 364 | call writefile(lines, 'XmessageMode', 'D') |
| 365 | let buf = RunVimInTerminal('-S XmessageMode', {'rows': 10}) |
| 366 | |
| 367 | call term_sendkeys(buf, 'gx') |
| 368 | call TermWait(buf) |
| 369 | call VerifyScreenDump(buf, 'Test_message_not_cleared_after_mode_1', {}) |
| 370 | |
| 371 | " removing the mode message used to also clear the intended message |
| 372 | call term_sendkeys(buf, 'vEgx') |
| 373 | call TermWait(buf) |
| 374 | call VerifyScreenDump(buf, 'Test_message_not_cleared_after_mode_2', {}) |
| 375 | |
Bram Moolenaar | da51ad5 | 2023-06-15 18:44:50 +0100 | [diff] [blame] | 376 | " removing the mode message used to also clear the error message |
| 377 | call term_sendkeys(buf, ":set cmdheight=2\<CR>") |
| 378 | call term_sendkeys(buf, '2GvEgf') |
| 379 | call TermWait(buf) |
| 380 | call VerifyScreenDump(buf, 'Test_message_not_cleared_after_mode_3', {}) |
| 381 | |
Bram Moolenaar | 800cdbb | 2023-06-15 16:40:02 +0100 | [diff] [blame] | 382 | call StopVimInTerminal(buf) |
| 383 | endfunc |
| 384 | |
Bram Moolenaar | 1190139 | 2022-09-26 19:50:44 +0100 | [diff] [blame] | 385 | " Test verbose message before echo command |
| 386 | func Test_echo_verbose_system() |
| 387 | CheckRunVimInTerminal |
Bram Moolenaar | f802767 | 2022-09-27 15:55:43 +0100 | [diff] [blame] | 388 | CheckUnix " needs the "seq" command |
| 389 | CheckNotMac " doesn't use /tmp |
Bram Moolenaar | 1190139 | 2022-09-26 19:50:44 +0100 | [diff] [blame] | 390 | |
| 391 | let buf = RunVimInTerminal('', {'rows': 10}) |
| 392 | call term_sendkeys(buf, ":4 verbose echo system('seq 20')\<CR>") |
| 393 | " Note that the screendump is filtered to remove the name of the temp file |
| 394 | call VerifyScreenDump(buf, 'Test_verbose_system_1', {}) |
| 395 | |
| 396 | " display a page and go back, results in exactly the same view |
| 397 | call term_sendkeys(buf, ' ') |
Bram Moolenaar | 19cf525 | 2022-11-27 14:39:31 +0000 | [diff] [blame] | 398 | call TermWait(buf, 50) |
Bram Moolenaar | 1190139 | 2022-09-26 19:50:44 +0100 | [diff] [blame] | 399 | call term_sendkeys(buf, 'b') |
| 400 | call VerifyScreenDump(buf, 'Test_verbose_system_1', {}) |
| 401 | |
| 402 | " do the same with 'cmdheight' set to 2 |
| 403 | call term_sendkeys(buf, 'q') |
| 404 | call TermWait(buf) |
| 405 | call term_sendkeys(buf, ":set ch=2\<CR>") |
| 406 | call TermWait(buf) |
| 407 | call term_sendkeys(buf, ":4 verbose echo system('seq 20')\<CR>") |
| 408 | call VerifyScreenDump(buf, 'Test_verbose_system_2', {}) |
| 409 | |
| 410 | call term_sendkeys(buf, ' ') |
Bram Moolenaar | 19cf525 | 2022-11-27 14:39:31 +0000 | [diff] [blame] | 411 | call TermWait(buf, 50) |
Bram Moolenaar | 1190139 | 2022-09-26 19:50:44 +0100 | [diff] [blame] | 412 | call term_sendkeys(buf, 'b') |
| 413 | call VerifyScreenDump(buf, 'Test_verbose_system_2', {}) |
| 414 | |
| 415 | call term_sendkeys(buf, 'q') |
| 416 | call TermWait(buf) |
| 417 | call StopVimInTerminal(buf) |
| 418 | endfunc |
| 419 | |
Bram Moolenaar | 838b746 | 2022-09-26 15:19:56 +0100 | [diff] [blame] | 420 | |
Bram Moolenaar | 43c60ed | 2020-02-02 15:55:19 +0100 | [diff] [blame] | 421 | func Test_ask_yesno() |
Bram Moolenaar | 494e906 | 2020-05-31 21:28:02 +0200 | [diff] [blame] | 422 | CheckRunVimInTerminal |
Bram Moolenaar | 43c60ed | 2020-02-02 15:55:19 +0100 | [diff] [blame] | 423 | let buf = RunVimInTerminal('', {'rows': 6}) |
| 424 | call term_sendkeys(buf, ":call setline(1, range(1, 2))\n") |
| 425 | |
| 426 | call term_sendkeys(buf, ":2,1s/^/n/\n") |
| 427 | call WaitForAssert({-> assert_equal('Backwards range given, OK to swap (y/n)?', term_getline(buf, 6))}) |
| 428 | call term_sendkeys(buf, "n") |
| 429 | call WaitForAssert({-> assert_match('^Backwards range given, OK to swap (y/n)?n *1,1 *All$', term_getline(buf, 6))}) |
| 430 | call WaitForAssert({-> assert_equal('1', term_getline(buf, 1))}) |
| 431 | |
| 432 | call term_sendkeys(buf, ":2,1s/^/Esc/\n") |
| 433 | call WaitForAssert({-> assert_equal('Backwards range given, OK to swap (y/n)?', term_getline(buf, 6))}) |
| 434 | call term_sendkeys(buf, "\<Esc>") |
| 435 | call WaitForAssert({-> assert_match('^Backwards range given, OK to swap (y/n)?n *1,1 *All$', term_getline(buf, 6))}) |
| 436 | call WaitForAssert({-> assert_equal('1', term_getline(buf, 1))}) |
| 437 | |
| 438 | call term_sendkeys(buf, ":2,1s/^/y/\n") |
| 439 | call WaitForAssert({-> assert_equal('Backwards range given, OK to swap (y/n)?', term_getline(buf, 6))}) |
| 440 | call term_sendkeys(buf, "y") |
| 441 | call WaitForAssert({-> assert_match('^Backwards range given, OK to swap (y/n)?y *2,1 *All$', term_getline(buf, 6))}) |
| 442 | call WaitForAssert({-> assert_equal('y1', term_getline(buf, 1))}) |
| 443 | call WaitForAssert({-> assert_equal('y2', term_getline(buf, 2))}) |
| 444 | |
Bram Moolenaar | c6d539b | 2019-12-28 17:10:46 +0100 | [diff] [blame] | 445 | call StopVimInTerminal(buf) |
| 446 | endfunc |
Bram Moolenaar | 9db2afe | 2020-01-08 18:56:20 +0100 | [diff] [blame] | 447 | |
| 448 | func Test_null() |
| 449 | echom test_null_list() |
| 450 | echom test_null_dict() |
| 451 | echom test_null_blob() |
Bram Moolenaar | 9db2afe | 2020-01-08 18:56:20 +0100 | [diff] [blame] | 452 | echom test_null_string() |
Bram Moolenaar | 92b83cc | 2020-04-25 15:24:44 +0200 | [diff] [blame] | 453 | echom test_null_function() |
Bram Moolenaar | 9db2afe | 2020-01-08 18:56:20 +0100 | [diff] [blame] | 454 | echom test_null_partial() |
Bram Moolenaar | da292b0 | 2020-01-08 19:27:40 +0100 | [diff] [blame] | 455 | if has('job') |
| 456 | echom test_null_job() |
| 457 | echom test_null_channel() |
| 458 | endif |
Bram Moolenaar | 9db2afe | 2020-01-08 18:56:20 +0100 | [diff] [blame] | 459 | endfunc |
Bram Moolenaar | 92b83cc | 2020-04-25 15:24:44 +0200 | [diff] [blame] | 460 | |
Bram Moolenaar | b42c0d5 | 2020-05-29 22:41:41 +0200 | [diff] [blame] | 461 | func Test_mapping_at_hit_return_prompt() |
| 462 | nnoremap <C-B> :echo "hit ctrl-b"<CR> |
| 463 | call feedkeys(":ls\<CR>", "xt") |
Bram Moolenaar | fccd93f | 2020-05-31 22:06:51 +0200 | [diff] [blame] | 464 | call feedkeys("\<*C-B>", "xt") |
Bram Moolenaar | b42c0d5 | 2020-05-29 22:41:41 +0200 | [diff] [blame] | 465 | call assert_match('hit ctrl-b', Screenline(&lines - 1)) |
| 466 | nunmap <C-B> |
| 467 | endfunc |
| 468 | |
Bram Moolenaar | 3d30af8 | 2020-10-13 22:15:56 +0200 | [diff] [blame] | 469 | func Test_quit_long_message() |
| 470 | CheckScreendump |
| 471 | |
| 472 | let content =<< trim END |
| 473 | echom range(9999)->join("\x01") |
| 474 | END |
Bram Moolenaar | 124af71 | 2022-09-25 18:44:03 +0100 | [diff] [blame] | 475 | call writefile(content, 'Xtest_quit_message', 'D') |
| 476 | let buf = RunVimInTerminal('-S Xtest_quit_message', #{rows: 10, wait_for_ruler: 0}) |
| 477 | call WaitForAssert({-> assert_match('^-- More --', term_getline(buf, 10))}) |
Bram Moolenaar | 3d30af8 | 2020-10-13 22:15:56 +0200 | [diff] [blame] | 478 | call term_sendkeys(buf, "q") |
| 479 | call VerifyScreenDump(buf, 'Test_quit_long_message', {}) |
| 480 | |
| 481 | " clean up |
| 482 | call StopVimInTerminal(buf) |
Bram Moolenaar | 3d30af8 | 2020-10-13 22:15:56 +0200 | [diff] [blame] | 483 | endfunc |
| 484 | |
Bram Moolenaar | 2de5371 | 2021-12-19 11:06:35 +0000 | [diff] [blame] | 485 | " this was missing a terminating NUL |
| 486 | func Test_echo_string_partial() |
| 487 | function CountSpaces() |
| 488 | endfunction |
Yegappan Lakshmanan | bc404bf | 2021-12-19 19:19:31 +0000 | [diff] [blame] | 489 | call assert_equal("function('CountSpaces', [{'ccccccccccc': ['ab', 'cd'], 'aaaaaaaaaaa': v:false, 'bbbbbbbbbbbb': ''}])", string(function('CountSpaces', [#{aaaaaaaaaaa: v:false, bbbbbbbbbbbb: '', ccccccccccc: ['ab', 'cd']}]))) |
Bram Moolenaar | 2de5371 | 2021-12-19 11:06:35 +0000 | [diff] [blame] | 490 | endfunc |
| 491 | |
zeertzjq | 40ed671 | 2023-11-23 20:37:01 +0100 | [diff] [blame] | 492 | " Test that fileinfo is shown properly when 'cmdheight' has just decreased |
| 493 | " due to switching tabpage and 'shortmess' doesn't contain 'o' or 'O'. |
| 494 | func Test_fileinfo_tabpage_cmdheight() |
| 495 | CheckRunVimInTerminal |
| 496 | |
| 497 | let content =<< trim END |
| 498 | set shortmess-=o |
| 499 | set shortmess-=O |
| 500 | set shortmess-=F |
| 501 | tabnew |
| 502 | set cmdheight=2 |
| 503 | tabprev |
| 504 | edit Xfileinfo.txt |
| 505 | END |
| 506 | |
| 507 | call writefile(content, 'Xtest_fileinfo_tabpage_cmdheight', 'D') |
| 508 | let buf = RunVimInTerminal('-S Xtest_fileinfo_tabpage_cmdheight', #{rows: 6}) |
| 509 | call WaitForAssert({-> assert_match('^"Xfileinfo.txt" \[New\]', term_getline(buf, 6))}) |
| 510 | |
| 511 | " clean up |
| 512 | call StopVimInTerminal(buf) |
| 513 | endfunc |
| 514 | |
Rob Pilling | 726f7f9 | 2022-01-20 14:44:38 +0000 | [diff] [blame] | 515 | " Message output was previously overwritten by the fileinfo display, shown |
| 516 | " when switching buffers. If a buffer is switched to, then a message if |
| 517 | " echoed, we should show the message, rather than overwriting it with |
| 518 | " fileinfo. |
| 519 | func Test_fileinfo_after_echo() |
| 520 | CheckScreendump |
| 521 | |
| 522 | let content =<< trim END |
| 523 | file a.txt |
| 524 | |
| 525 | hide edit b.txt |
| 526 | call setline(1, "hi") |
| 527 | setlocal modified |
| 528 | |
| 529 | hide buffer a.txt |
| 530 | |
Bram Moolenaar | 9323ca5 | 2022-03-16 11:14:57 +0000 | [diff] [blame] | 531 | autocmd CursorHold * buf b.txt | w | echo "'b' written" |
Rob Pilling | 726f7f9 | 2022-01-20 14:44:38 +0000 | [diff] [blame] | 532 | END |
| 533 | |
Bram Moolenaar | b152b6a | 2022-09-29 21:37:33 +0100 | [diff] [blame] | 534 | call writefile(content, 'Xtest_fileinfo_after_echo', 'D') |
Rob Pilling | 726f7f9 | 2022-01-20 14:44:38 +0000 | [diff] [blame] | 535 | let buf = RunVimInTerminal('-S Xtest_fileinfo_after_echo', #{rows: 6}) |
Bram Moolenaar | 9323ca5 | 2022-03-16 11:14:57 +0000 | [diff] [blame] | 536 | call term_sendkeys(buf, ":set updatetime=50\<CR>") |
| 537 | call term_sendkeys(buf, "0$") |
Rob Pilling | 726f7f9 | 2022-01-20 14:44:38 +0000 | [diff] [blame] | 538 | call VerifyScreenDump(buf, 'Test_fileinfo_after_echo', {}) |
| 539 | |
| 540 | call term_sendkeys(buf, ":q\<CR>") |
| 541 | |
| 542 | " clean up |
| 543 | call StopVimInTerminal(buf) |
Yegappan Lakshmanan | 7e765a3 | 2022-01-24 11:40:37 +0000 | [diff] [blame] | 544 | call delete('b.txt') |
Rob Pilling | 726f7f9 | 2022-01-20 14:44:38 +0000 | [diff] [blame] | 545 | endfunc |
| 546 | |
Bram Moolenaar | 37fef16 | 2022-08-29 18:16:32 +0100 | [diff] [blame] | 547 | func Test_echowindow() |
| 548 | CheckScreendump |
| 549 | |
| 550 | let lines =<< trim END |
| 551 | call setline(1, 'some text') |
| 552 | func ShowMessage(arg) |
| 553 | echowindow a:arg |
| 554 | endfunc |
| 555 | echowindow 'first line' |
Bram Moolenaar | b5b4f61 | 2022-09-01 16:43:17 +0100 | [diff] [blame] | 556 | func ManyMessages() |
| 557 | for n in range(20) |
| 558 | echowindow 'line' n |
| 559 | endfor |
| 560 | endfunc |
Bram Moolenaar | cf0995d | 2022-09-11 21:36:17 +0100 | [diff] [blame] | 561 | |
| 562 | def TwoMessages() |
| 563 | popup_clear() |
| 564 | set cmdheight=2 |
| 565 | redraw |
| 566 | timer_start(100, (_) => { |
| 567 | echowin 'message' |
| 568 | }) |
| 569 | echo 'one' |
| 570 | echo 'two' |
| 571 | enddef |
| 572 | |
| 573 | def ThreeMessages() |
| 574 | popup_clear() |
| 575 | redraw |
| 576 | timer_start(100, (_) => { |
| 577 | echowin 'later message' |
| 578 | }) |
| 579 | echo 'one' |
| 580 | echo 'two' |
| 581 | echo 'three' |
| 582 | enddef |
Bram Moolenaar | bdc09a1 | 2022-10-07 14:31:45 +0100 | [diff] [blame] | 583 | |
| 584 | def HideWin() |
| 585 | popup_hide(popup_findecho()) |
| 586 | enddef |
Bram Moolenaar | 37fef16 | 2022-08-29 18:16:32 +0100 | [diff] [blame] | 587 | END |
Bram Moolenaar | b152b6a | 2022-09-29 21:37:33 +0100 | [diff] [blame] | 588 | call writefile(lines, 'XtestEchowindow', 'D') |
Bram Moolenaar | 37fef16 | 2022-08-29 18:16:32 +0100 | [diff] [blame] | 589 | let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8}) |
| 590 | call VerifyScreenDump(buf, 'Test_echowindow_1', {}) |
| 591 | |
| 592 | call term_sendkeys(buf, ":call ShowMessage('second line')\<CR>") |
| 593 | call VerifyScreenDump(buf, 'Test_echowindow_2', {}) |
| 594 | |
| 595 | call term_sendkeys(buf, ":call popup_clear()\<CR>") |
| 596 | call VerifyScreenDump(buf, 'Test_echowindow_3', {}) |
| 597 | |
Bram Moolenaar | b5b4f61 | 2022-09-01 16:43:17 +0100 | [diff] [blame] | 598 | call term_sendkeys(buf, ":call ManyMessages()\<CR>") |
| 599 | call VerifyScreenDump(buf, 'Test_echowindow_4', {}) |
| 600 | |
Bram Moolenaar | cf0995d | 2022-09-11 21:36:17 +0100 | [diff] [blame] | 601 | call term_sendkeys(buf, ":call TwoMessages()\<CR>") |
| 602 | call VerifyScreenDump(buf, 'Test_echowindow_5', {}) |
| 603 | |
| 604 | call term_sendkeys(buf, ":call ThreeMessages()\<CR>") |
| 605 | sleep 120m |
| 606 | call VerifyScreenDump(buf, 'Test_echowindow_6', {}) |
| 607 | |
| 608 | call term_sendkeys(buf, "\<CR>") |
| 609 | call VerifyScreenDump(buf, 'Test_echowindow_7', {}) |
| 610 | |
Bram Moolenaar | 4569020 | 2022-09-26 12:57:11 +0100 | [diff] [blame] | 611 | call term_sendkeys(buf, ":tabnew\<CR>") |
Bram Moolenaar | bdc09a1 | 2022-10-07 14:31:45 +0100 | [diff] [blame] | 612 | call term_sendkeys(buf, ":7echowin 'more'\<CR>") |
Bram Moolenaar | 4569020 | 2022-09-26 12:57:11 +0100 | [diff] [blame] | 613 | call VerifyScreenDump(buf, 'Test_echowindow_8', {}) |
| 614 | |
Bram Moolenaar | bdc09a1 | 2022-10-07 14:31:45 +0100 | [diff] [blame] | 615 | call term_sendkeys(buf, ":call HideWin()\<CR>") |
| 616 | call VerifyScreenDump(buf, 'Test_echowindow_9', {}) |
| 617 | |
Bram Moolenaar | 37fef16 | 2022-08-29 18:16:32 +0100 | [diff] [blame] | 618 | " clean up |
| 619 | call StopVimInTerminal(buf) |
Bram Moolenaar | 37fef16 | 2022-08-29 18:16:32 +0100 | [diff] [blame] | 620 | endfunc |
| 621 | |
Yasuhiro Matsumoto | a02a8a4 | 2022-09-02 12:16:21 +0100 | [diff] [blame] | 622 | " messages window should not be used while evaluating the :echowin argument |
| 623 | func Test_echowin_eval() |
| 624 | CheckScreendump |
| 625 | |
| 626 | let lines =<< trim END |
| 627 | func ShowMessage() |
| 628 | echo 123 |
| 629 | return 'test' |
| 630 | endfunc |
| 631 | echowindow ShowMessage() |
| 632 | END |
Bram Moolenaar | b152b6a | 2022-09-29 21:37:33 +0100 | [diff] [blame] | 633 | call writefile(lines, 'XtestEchowindow', 'D') |
Yasuhiro Matsumoto | a02a8a4 | 2022-09-02 12:16:21 +0100 | [diff] [blame] | 634 | let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8}) |
| 635 | call VerifyScreenDump(buf, 'Test_echowin_eval', {}) |
| 636 | |
| 637 | " clean up |
| 638 | call StopVimInTerminal(buf) |
Yasuhiro Matsumoto | a02a8a4 | 2022-09-02 12:16:21 +0100 | [diff] [blame] | 639 | endfunc |
| 640 | |
Bram Moolenaar | 7cf5839 | 2022-09-09 20:19:40 +0100 | [diff] [blame] | 641 | " messages window should not be used for showing the mode |
| 642 | func Test_echowin_showmode() |
| 643 | CheckScreendump |
| 644 | |
| 645 | let lines =<< trim END |
| 646 | vim9script |
| 647 | setline(1, ['one', 'two']) |
| 648 | timer_start(100, (_) => { |
| 649 | echowin 'echo window' |
| 650 | }) |
| 651 | normal V |
| 652 | END |
| 653 | call writefile(lines, 'XtestEchowinMode', 'D') |
| 654 | let buf = RunVimInTerminal('-S XtestEchowinMode', #{rows: 8}) |
| 655 | call VerifyScreenDump(buf, 'Test_echowin_showmode', {}) |
| 656 | |
| 657 | " clean up |
| 658 | call StopVimInTerminal(buf) |
| 659 | endfunc |
| 660 | |
Christian Brabandt | 51d4d84 | 2024-12-06 17:26:25 +0100 | [diff] [blame] | 661 | func Test_messagesopt_history() |
| 662 | " After setting 'messagesopt' "history" to 2 and outputting a message 4 times |
| 663 | " with :echomsg, is the number of output lines of :messages 2? |
| 664 | set messagesopt=hit-enter,history:2 |
| 665 | echomsg 'foo' |
| 666 | echomsg 'bar' |
| 667 | echomsg 'baz' |
| 668 | echomsg 'foobar' |
| 669 | call assert_equal(['baz', 'foobar'], GetMessages()) |
| 670 | |
| 671 | " When the number of messages is 10 and 'messagesopt' "history" is changed to |
| 672 | " 5, is the number of output lines of :messages 5? |
| 673 | set messagesopt=hit-enter,history:10 |
| 674 | for num in range(1, 10) |
| 675 | echomsg num |
| 676 | endfor |
| 677 | set messagesopt=hit-enter,history:5 |
| 678 | call assert_equal(5, len(GetMessages())) |
| 679 | |
| 680 | " Check empty list |
| 681 | set messagesopt=hit-enter,history:0 |
| 682 | call assert_true(empty(GetMessages())) |
| 683 | |
| 684 | set messagesopt& |
| 685 | endfunc |
| 686 | |
| 687 | func Test_messagesopt_wait() |
| 688 | CheckRunVimInTerminal |
| 689 | |
| 690 | let buf = RunVimInTerminal('', {'rows': 6, 'cols': 45}) |
| 691 | call term_sendkeys(buf, ":set cmdheight=1\n") |
| 692 | |
| 693 | " Check hit-enter prompt |
| 694 | call term_sendkeys(buf, ":set messagesopt=hit-enter,history:500\n") |
| 695 | call term_sendkeys(buf, ":echo 'foo' | echo 'bar' echo 'baz'\n") |
| 696 | call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) |
| 697 | |
| 698 | " Check no hit-enter prompt when "wait:" is set |
| 699 | call term_sendkeys(buf, ":set messagesopt=wait:100,history:500\n") |
| 700 | call term_sendkeys(buf, ":echo 'foo' | echo 'bar' echo 'baz'\n") |
| 701 | call WaitForAssert({-> assert_equal(' 0,0-1 All', term_getline(buf, 6))}) |
| 702 | |
| 703 | " clean up |
| 704 | call StopVimInTerminal(buf) |
| 705 | endfunc |
Bram Moolenaar | 4356864 | 2022-08-28 13:02:45 +0100 | [diff] [blame] | 706 | |
Bram Moolenaar | 92b83cc | 2020-04-25 15:24:44 +0200 | [diff] [blame] | 707 | " vim: shiftwidth=2 sts=2 expandtab |