tui: fix handling of bg response after suspend (#11145)

`tui_terminal_after_startup` gets called right after resuming from
suspending (via `Ctrl-z`) already (not delayed as with the startup
itself), and would set `waiting_for_bg_response` to false then directly.
This results in the terminal response not being processed then anymore,
and leaking into Neovim itself.

This changes it to try 5 times always, which means that it typically
would stop after a few characters of input from the user typically, e.g.
with tmux, which does not send a reply.

While it might be better to have something based on the time (e.g. only
wait for max 1s), this appears to be easier to do.

Fixes regression in 8a4ae3d.
This commit is contained in:
Daniel Hahler
2019-10-03 08:04:24 +02:00
committed by GitHub
parent 30479417e8
commit f96d1e6bc4
4 changed files with 18 additions and 22 deletions

View File

@@ -16,7 +16,7 @@ itp('handle_background_color', function()
local events = globals.main_loop.thread_events
-- Short-circuit when not waiting for response.
term_input.waiting_for_bg_response = false
term_input.waiting_for_bg_response = 0
eq(false, handle_background_color(term_input))
local capacity = 100
@@ -27,9 +27,9 @@ itp('handle_background_color', function()
local term_response = '\027]11;'..colorspace..':'..color..'\007'
rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response)
term_input.waiting_for_bg_response = true
term_input.waiting_for_bg_response = 1
eq(true, handle_background_color(term_input))
eq(false, term_input.waiting_for_bg_response)
eq(0, term_input.waiting_for_bg_response)
eq(1, multiqueue.multiqueue_size(events))
local event = multiqueue.multiqueue_get(events)
@@ -101,10 +101,9 @@ itp('handle_background_color', function()
local term_response = '\027]11;rgba:f/f/f/f' -- missing '\007
rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response)
term_input.waiting_for_bg_response = true
eq(true, term_input.waiting_for_bg_response)
term_input.waiting_for_bg_response = 1
eq(false, handle_background_color(term_input))
eq(false, term_input.waiting_for_bg_response)
eq(0, term_input.waiting_for_bg_response)
eq(0, multiqueue.multiqueue_size(events))
eq(0, rbuf.size)
@@ -114,10 +113,9 @@ itp('handle_background_color', function()
term_response = '123\027]11;rgba:f/f/f/f\007456'
rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response)
term_input.waiting_for_bg_response = true
eq(true, term_input.waiting_for_bg_response)
term_input.waiting_for_bg_response = 3
eq(false, handle_background_color(term_input))
eq(true, term_input.waiting_for_bg_response)
eq(2, term_input.waiting_for_bg_response)
eq(0, multiqueue.multiqueue_size(events))
eq(#term_response, rbuf.size)
@@ -128,10 +126,9 @@ itp('handle_background_color', function()
term_response = '\027]11;rgba:f/f/f/f\007456'
rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response)
term_input.waiting_for_bg_response = true
eq(true, term_input.waiting_for_bg_response)
term_input.waiting_for_bg_response = 1
eq(true, handle_background_color(term_input))
eq(false, term_input.waiting_for_bg_response)
eq(0, term_input.waiting_for_bg_response)
eq(1, multiqueue.multiqueue_size(events))
eq(3, rbuf.size)