|
1 | 1 | " Tests for :messages, :echomsg, :echoerr |
2 | 2 |
|
| 3 | +source shared.vim |
| 4 | + |
3 | 5 | function Test_messages() |
4 | 6 | let oldmore = &more |
5 | 7 | try |
@@ -92,3 +94,34 @@ func Test_echoerr() |
92 | 94 | call assert_match("function('<lambda>\\d*')", execute(':echoerr {-> 1234}')) |
93 | 95 | call test_ignore_error('RESET') |
94 | 96 | endfunc |
| 97 | + |
| 98 | +func Test_mode_message_at_leaving_insert_by_ctrl_c() |
| 99 | + if !has('terminal') || has('gui_running') |
| 100 | + return |
| 101 | + endif |
| 102 | + |
| 103 | + " Set custom statusline built by user-defined function. |
| 104 | + let testfile = 'Xtest.vim' |
| 105 | + call writefile([ |
| 106 | + \ 'func StatusLine() abort', |
| 107 | + \ ' return ""', |
| 108 | + \ 'endfunc', |
| 109 | + \ 'set statusline=%!StatusLine()', |
| 110 | + \ 'set laststatus=2', |
| 111 | + \ ], testfile) |
| 112 | + |
| 113 | + let rows = 10 |
| 114 | + let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows}) |
| 115 | + call term_wait(buf, 200) |
| 116 | + call assert_equal('run', job_status(term_getjob(buf))) |
| 117 | + |
| 118 | + call term_sendkeys(buf, "i") |
| 119 | + call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))}) |
| 120 | + call term_sendkeys(buf, "\<C-C>") |
| 121 | + call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))}) |
| 122 | + |
| 123 | + call term_sendkeys(buf, ":qall!\<CR>") |
| 124 | + call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))}) |
| 125 | + exe buf . 'bwipe!' |
| 126 | + call delete(testfile) |
| 127 | +endfunc |
0 commit comments