fix(exmode): flush messages before printing a line after pressing Enter (#19341)

This commit is contained in:
zeertzjq 2022-07-13 09:06:31 +08:00 committed by GitHub
parent 39d51c833a
commit c01690b1ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 2 deletions

View File

@ -227,13 +227,14 @@ void do_exmode(void)
emsg(_(e_emptybuf)); emsg(_(e_emptybuf));
} else { } else {
if (ex_pressedreturn) { if (ex_pressedreturn) {
// Make sure the message overwrites the right line and isn't throttled.
msg_scroll_flush();
// go up one line, to overwrite the ":<CR>" line, so the // go up one line, to overwrite the ":<CR>" line, so the
// output doesn't contain empty lines. // output doesn't contain empty lines.
msg_row = prev_msg_row; msg_row = prev_msg_row;
if (prev_msg_row == Rows - 1) { if (prev_msg_row == Rows - 1) {
msg_row--; msg_row--;
} }
msg_grid.throttled = false;
} }
msg_col = 0; msg_col = 0;
print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE); print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE);

View File

@ -104,10 +104,10 @@ describe('Ex mode', function()
-- Pressing enter in ex mode should print the current line -- Pressing enter in ex mode should print the current line
feed('<CR>') feed('<CR>')
screen:expect([[ screen:expect([[
{1: 1 }foo foo |
^^^y | ^^^y |
{1: 2 }foo foo | {1: 2 }foo foo |
^^^q | ^^^q |
{1: 2 }foo foo |
{1: 3 }foo foo | {1: 3 }foo foo |
:^ | :^ |
]]) ]])

View File

@ -1196,6 +1196,53 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
{4:Press ENTER or type command to continue}^ | {4:Press ENTER or type command to continue}^ |
]]} ]]}
end) end)
it('prints lines in Ex mode correctly with a burst of carriage returns #19341', function()
command('set number')
meths.buf_set_lines(0, 0, 0, true, {'aaa', 'bbb', 'ccc'})
command('set display-=msgsep')
feed('gggQ<CR><CR>1<CR><CR>vi')
screen:expect([[
Entering Ex mode. Type "visual" to go to Normal mode. |
{11: 2 }bbb |
{11: 3 }ccc |
:1 |
{11: 1 }aaa |
{11: 2 }bbb |
:vi^ |
]])
feed('<CR>')
screen:expect([[
{11: 1 }aaa |
{11: 2 }^bbb |
{11: 3 }ccc |
{11: 4 } |
{1:~ }|
{1:~ }|
|
]])
command('set display+=msgsep')
feed('gggQ<CR><CR>1<CR><CR>vi')
screen:expect([[
Entering Ex mode. Type "visual" to go to Normal mode. |
{11: 2 }bbb |
{11: 3 }ccc |
:1 |
{11: 1 }aaa |
{11: 2 }bbb |
:vi^ |
]])
feed('<CR>')
screen:expect([[
{11: 1 }aaa |
{11: 2 }^bbb |
{11: 3 }ccc |
{11: 4 } |
{1:~ }|
{1:~ }|
|
]])
end)
end) end)
describe('ui/ext_messages', function() describe('ui/ext_messages', function()