Merge pull request #12352 from jamessan/fix/hang-headless-mode

This commit is contained in:
James McCoy
2020-05-21 07:39:22 -04:00
committed by GitHub
2 changed files with 24 additions and 1 deletions

View File

@@ -2570,10 +2570,15 @@ static int do_more_prompt(int typed_char)
msgchunk_T *mp; msgchunk_T *mp;
int i; int i;
// If headless mode is enabled and no input is required, this variable
// will be true. However If server mode is enabled, the message "--more--"
// should be displayed.
bool no_need_more = headless_mode && !embedded_mode;
// We get called recursively when a timer callback outputs a message. In // We get called recursively when a timer callback outputs a message. In
// that case don't show another prompt. Also when at the hit-Enter prompt // that case don't show another prompt. Also when at the hit-Enter prompt
// and nothing was typed. // and nothing was typed.
if (entered || (State == HITRETURN && typed_char == 0)) { if (no_need_more || entered || (State == HITRETURN && typed_char == 0)) {
return false; return false;
} }
entered = true; entered = true;

View File

@@ -277,6 +277,24 @@ describe('startup', function()
[4] = {bold = true, foreground = Screen.colors.Blue1}, [4] = {bold = true, foreground = Screen.colors.Blue1},
}}) }})
end) end)
it('fixed hang issue with --headless (#11386)', function()
local expected = ''
local period = 100
for i = 1, period - 1 do
expected = expected .. i .. '\r\n'
end
expected = expected .. period
eq(
expected,
-- FIXME(codehex): We should really set a timeout for the system function.
-- If this test fails, there will be a waiting input state.
funcs.system({nvim_prog, '-u', 'NONE', '-c',
'for i in range(1, 100) | echo i | endfor | quit',
'--headless'
})
)
end)
end) end)
describe('sysinit', function() describe('sysinit', function()