vim-patch:8.1.0822: peeking and flushing output slows down execution

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:
Jan Edmund Lazo 2019-07-20 18:28:16 -04:00
parent 84faeb07d0
commit 0519a75f6e
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
7 changed files with 29 additions and 14 deletions

View File

@ -7803,7 +7803,7 @@ static bool ins_esc(long *count, int cmdchar, bool nomove)
// Otherwise remove the mode message. // Otherwise remove the mode message.
if (reg_recording != 0 || restart_edit != NUL) { if (reg_recording != 0 || restart_edit != NUL) {
showmode(); showmode();
} else if (p_smd) { } else if (p_smd && !skip_showmode()) {
MSG(""); MSG("");
} }
// Exit Insert mode // Exit Insert mode

View File

@ -2490,8 +2490,10 @@ int inchar(
} }
// 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

@ -6557,6 +6557,21 @@ void grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
return; return;
} }
// Return true when postponing displaying the mode message: when not redrawing
// or inside a mapping.
bool skip_showmode(void)
{
// Call char_avail() only when we are going to show something, because it
// takes a bit of time. redrawing() may also call char_avail_avail().
if (global_busy
|| msg_silent != 0
|| !redrawing()
|| (char_avail() && !KeyTyped)) {
redraw_cmdline = true; // show mode later
return true;
}
return false;
}
// Show the current mode and ruler. // Show the current mode and ruler.
// //
@ -6588,12 +6603,8 @@ int showmode(void)
|| restart_edit || restart_edit
|| VIsual_active)); || VIsual_active));
if (do_mode || reg_recording != 0) { if (do_mode || reg_recording != 0) {
// Don't show mode right now, when not redrawing or inside a mapping. if (skip_showmode()) {
// Call char_avail() only when we are going to show something, because return 0; // show mode later
// it takes a bit of time.
if (!redrawing() || (char_avail() && !KeyTyped) || msg_silent != 0) {
redraw_cmdline = TRUE; /* show mode later */
return 0;
} }
nwr_save = need_wait_return; nwr_save = need_wait_return;

View File

@ -121,7 +121,7 @@ describe('NULL', function()
null_test('does not make Neovim crash when v:oldfiles gets assigned to that', ':let v:oldfiles = L|oldfiles', 0) null_test('does not make Neovim crash when v:oldfiles gets assigned to that', ':let v:oldfiles = L|oldfiles', 0)
null_expr_test('does not make complete() crash or error out', null_expr_test('does not make complete() crash or error out',
'execute(":normal i\\<C-r>=complete(1, L)[-1]\\n")', 'execute(":normal i\\<C-r>=complete(1, L)[-1]\\n")',
'', '\n', function() 0, '', function()
eq({''}, curbufmeths.get_lines(0, -1, false)) eq({''}, curbufmeths.get_lines(0, -1, false))
end) end)
null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, 0) null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, 0)

View File

@ -130,12 +130,12 @@ describe('timers', function()
nvim_async("command", "call timer_start("..load_adjust(100)..", 'AddItem', {'repeat': -1})") nvim_async("command", "call timer_start("..load_adjust(100)..", 'AddItem', {'repeat': -1})")
screen:expect([[ screen:expect([[
ITEM 1 | ^ITEM 1 |
ITEM 2 | ITEM 2 |
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
^ | |
]]) ]])
nvim_async("command", "let g:cont = 1") nvim_async("command", "let g:cont = 1")

View File

@ -391,7 +391,7 @@ describe('TUI', function()
{1:x} | {1:x} |
{4:~ }| {4:~ }|
{5:[No Name] [+] 3,1 All}| {5:[No Name] [+] 3,1 All}|
| :set ruler |
{3:-- TERMINAL --} | {3:-- TERMINAL --} |
]] ]]
local expected_attr = { local expected_attr = {

View File

@ -807,7 +807,9 @@ function Screen:_handle_mouse_off()
end end
function Screen:_handle_mode_change(mode, idx) function Screen:_handle_mode_change(mode, idx)
assert(mode == self._mode_info[idx+1].name) if self._mode_info ~= nil then
assert(mode == self._mode_info[idx+1].name)
end
self.mode = mode self.mode = mode
end end