diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-03-10 13:31:05 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-03-11 08:43:27 +0100 |
commit | 43184566aafdd3ed9e787775c83ba6b73faa0cf6 (patch) | |
tree | 217a2f72c6a74307153dbfe01b88da66c13ca513 /test | |
parent | ef5037e7f6e199ade4475d819842e66eb3bd8381 (diff) | |
download | rneovim-43184566aafdd3ed9e787775c83ba6b73faa0cf6.tar.gz rneovim-43184566aafdd3ed9e787775c83ba6b73faa0cf6.tar.bz2 rneovim-43184566aafdd3ed9e787775c83ba6b73faa0cf6.zip |
TUI/background detection: hook into VimEnter event
If terminal response is received during startup, set 'background' from
a nested "one-shot" (once) VimEnter autocmd.
The previous not-so-clever "self-rescheduling" approach could cause
a long delay at startup (event-loop does not make forward progress).
fixes #9675
ref #9509
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index a0adb45630..2017c57828 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -839,8 +839,7 @@ describe('TUI background color', function() it("triggers OptionSet event on terminal-response", function() feed_data('\027:autocmd OptionSet background echo "did OptionSet, yay!"\n') - -- The child Nvim is running asynchronously; wait for it to register the - -- OptionSet handler. + -- Wait for the child Nvim to register the OptionSet handler. feed_data('\027:autocmd OptionSet\n') screen:expect({any='--- Autocommands ---'}) @@ -860,8 +859,14 @@ describe('TUI background color', function() local function assert_bg(color, bg) it('handles '..color..' as '..bg, function() - feed_data('\027]11;rgb:'..color..'\007:echo &background\n') - screen:expect(string.format([[ + feed_data('\027:autocmd OptionSet background :echo &background\n') + + -- Wait for the child Nvim to register the OptionSet handler. + feed_data('\027:autocmd OptionSet\n') + screen:expect({any='--- Autocommands ---'}) + + feed_data('\012') -- CTRL-L: clear the screen + local expected_grid = [[ {1: } | {4:~ }| {4:~ }| @@ -869,7 +874,17 @@ describe('TUI background color', function() {5:[No Name] 0,0-1 All}| %-5s | {3:-- TERMINAL --} | - ]], bg)) + ]] + screen:expect(string.format(expected_grid, '')) + + feed_data('\027]11;rgb:'..color..'\007') + -- Because bg=dark is the default, we do NOT expect OptionSet event. + if bg == 'dark' then + screen:expect{unchanged=true, + grid=string.format(expected_grid, '')} + else + screen:expect(string.format(expected_grid, bg)) + end end) end |