vim-patch:8.1.0822: peeking and flushing output slows down execution (#25629)

Problem:    Peeking and flushing output slows down execution.
Solution:   Do not update the mode message when global_busy is set.  Do not
            flush when only peeking for a character. (Ken Takata)

cb574f4154
This commit is contained in:
zeertzjq 2023-10-14 09:58:30 +08:00 committed by GitHub
parent 9f32deba56
commit bf70a33f5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 64 additions and 45 deletions

View File

@ -3287,5 +3287,5 @@ static void win_put_linebuf(win_T *wp, int row, int coloff, int endcol, int clea
} }
grid_adjust(&grid, &row, &coloff); grid_adjust(&grid, &row, &coloff);
grid_put_linebuf(grid, row, coloff, 0, endcol, clear_width, wp->w_p_rl, bg_attr, wrap, false); grid_put_linebuf(grid, row, coloff, 0, endcol, clear_width, wp->w_p_rl, bg_attr, wrap);
} }

View File

@ -2861,8 +2861,10 @@ int inchar(uint8_t *buf, int maxlen, long wait_time)
} }
// Always flush the output characters when getting input characters // Always flush the output characters when getting input characters
// from the user. // from the user and not just peeking.
ui_flush(); if (wait_time == -1L || wait_time > 10L) {
ui_flush();
}
// Fill up to a third of the buffer, because each character may be // Fill up to a third of the buffer, because each character may be
// tripled below. // tripled below.

View File

@ -481,11 +481,8 @@ void grid_line_flush(void)
return; return;
} }
int row = grid_line_row; grid_put_linebuf(grid, grid_line_row, grid_line_coloff, grid_line_first, grid_line_last,
grid_line_last, false, 0, false);
bool invalid_row = grid != &default_grid && grid_invalid_row(grid, row) && grid_line_first == 0;
grid_put_linebuf(grid, row, grid_line_coloff, grid_line_first, grid_line_last, grid_line_last,
false, 0, false, invalid_row);
} }
/// flush grid line but only if on a valid row /// flush grid line but only if on a valid row
@ -620,7 +617,7 @@ static int grid_char_needs_redraw(ScreenGrid *grid, int col, size_t off_to, int
/// If "wrap" is true, then hint to the UI that "row" contains a line /// If "wrap" is true, then hint to the UI that "row" contains a line
/// which has wrapped into the next row. /// which has wrapped into the next row.
void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int col, int endcol, int clear_width, void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int col, int endcol, int clear_width,
bool rl, int bg_attr, bool wrap, bool invalid_row) bool rl, int bg_attr, bool wrap)
{ {
bool redraw_next; // redraw_this for next character bool redraw_next; // redraw_this for next character
bool clear_next = false; bool clear_next = false;
@ -639,6 +636,7 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int col, int endcol
return; return;
} }
bool invalid_row = grid != &default_grid && grid_invalid_row(grid, row) && col == 0;
size_t off_to = grid->line_offset[row] + (size_t)coloff; size_t off_to = grid->line_offset[row] + (size_t)coloff;
const size_t max_off_to = grid->line_offset[row] + (size_t)grid->cols; const size_t max_off_to = grid->line_offset[row] + (size_t)grid->cols;

View File

@ -77,8 +77,7 @@ describe('vim.ui_attach', function()
} }
feed '<c-y>' feed '<c-y>'
-- There is an intermediate state where the 'showmode' message disappears. screen:expect_unchanged()
screen:expect_unchanged(true)
expect_events { expect_events {
{ "popupmenu_hide" }; { "popupmenu_hide" };
} }

View File

@ -1775,30 +1775,36 @@ describe('extmark decorations', function()
]]) ]])
-- When only one highlight group has an underline attribute, it should always take effect. -- When only one highlight group has an underline attribute, it should always take effect.
meths.buf_clear_namespace(0, ns, 0, -1) for _, d in ipairs({-5, 5}) do
meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 20 }) meths.buf_clear_namespace(0, ns, 0, -1)
meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 30 }) screen:expect([[
screen:expect([[ aaabbbaa^a |
{1:aaa}{5:bbb}{1:aa^a} | {0:~ }|
{0:~ }| |
| ]])
]]) meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 25 + d })
meths.buf_clear_namespace(0, ns, 0, -1) meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 25 - d })
meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 30 }) screen:expect([[
meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 20 }) {1:aaa}{5:bbb}{1:aa^a} |
screen:expect_unchanged(true) {0:~ }|
meths.buf_clear_namespace(0, ns, 0, -1) |
meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 20 }) ]])
meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 30 }) end
screen:expect([[ for _, d in ipairs({-5, 5}) do
{2:aaa}{6:bbb}{2:aa^a} | meths.buf_clear_namespace(0, ns, 0, -1)
{0:~ }| screen:expect([[
| aaabbbaa^a |
]]) {0:~ }|
meths.buf_clear_namespace(0, ns, 0, -1) |
meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 30 }) ]])
meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 20 }) meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 25 + d })
screen:expect_unchanged(true) meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 25 - d })
screen:expect([[
{2:aaa}{6:bbb}{2:aa^a} |
{0:~ }|
|
]])
end
end) end)
it('highlight is combined with syntax and sign linehl #20004', function() it('highlight is combined with syntax and sign linehl #20004', function()

View File

@ -9284,9 +9284,11 @@ describe('float window', function()
end end
-- Also test with global NormalNC highlight -- Also test with global NormalNC highlight
meths.set_option_value('winhighlight', '', {win = win}) exec_lua([[
command('hi link NormalNC Visual') vim.api.nvim_set_option_value('winhighlight', '', {win = ...})
screen:expect_unchanged(true) vim.api.nvim_set_hl(0, 'NormalNC', {link = 'Visual'})
]], win)
screen:expect_unchanged()
command('hi clear NormalNC') command('hi clear NormalNC')
command('hi SpecialRegion guifg=Red blend=0') command('hi SpecialRegion guifg=Red blend=0')

View File

@ -169,10 +169,10 @@ describe("folded lines", function()
end end
-- CursorLine is applied correctly with screenrow motions #22232 -- CursorLine is applied correctly with screenrow motions #22232
feed("jgk") feed("jgk")
screen:expect_unchanged(true) screen:expect_unchanged()
-- CursorLine is applied correctly when closing a fold when cursor is not at fold start -- CursorLine is applied correctly when closing a fold when cursor is not at fold start
feed("zo4Gzc") feed("zo4Gzc")
screen:expect_unchanged(true) screen:expect_unchanged()
command("set cursorlineopt=line") command("set cursorlineopt=line")
if multigrid then if multigrid then
screen:expect([[ screen:expect([[

View File

@ -2929,7 +2929,16 @@ it(':substitute with inccommand, allows :redraw before first separator is typed
meths.open_win(float_buf, false, { meths.open_win(float_buf, false, {
relative = 'editor', height = 1, width = 5, row = 3, col = 0, focusable = false, relative = 'editor', height = 1, width = 5, row = 3, col = 0, focusable = false,
}) })
feed(':%s') feed(':')
screen:expect([[
foo bar baz |
bar baz fox |
bar foo baz |
{16: }{15: }|
{15:~ }|
:^ |
]])
feed('%s')
screen:expect([[ screen:expect([[
foo bar baz | foo bar baz |
bar baz fox | bar baz fox |

View File

@ -69,15 +69,18 @@ describe('UI receives option updates', function()
eq({'mouse_on'}, evs) eq({'mouse_on'}, evs)
end) end)
command("set mouse=") command("set mouse=")
screen:expect(function()
eq({'mouse_on', 'mouse_off'}, evs)
end)
command("set mouse&") command("set mouse&")
screen:expect(function() screen:expect(function()
eq({'mouse_on','mouse_off', 'mouse_on'}, evs) eq({'mouse_on', 'mouse_off', 'mouse_on'}, evs)
end) end)
screen:detach() screen:detach()
eq({'mouse_on','mouse_off', 'mouse_on'}, evs) eq({'mouse_on', 'mouse_off', 'mouse_on'}, evs)
screen:attach() screen:attach()
screen:expect(function() screen:expect(function()
eq({'mouse_on','mouse_off','mouse_on', 'mouse_on'}, evs) eq({'mouse_on', 'mouse_off', 'mouse_on', 'mouse_on'}, evs)
end) end)
end) end)

View File

@ -337,7 +337,7 @@ describe('search highlighting', function()
]]) ]])
feed('/foo') feed('/foo')
helpers.poke_eventloop() helpers.poke_eventloop()
screen:sleep(0) screen:sleep(100)
screen:expect_unchanged() screen:expect_unchanged()
end) end)