Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/nvim/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,14 @@ int main(int argc, char **argv)
// Execute any "+", "-c" and "-S" arguments.
if (params.n_commands > 0) {
exe_commands(&params);
// If in headless mode, we need to exit at this point.
// If we continue, we will enter the normal mode and the
// message "Press ENTER or type command to continue" will be
// displayed and we will be in the input waiting state.
if (headless_mode) {
msg_putchar('\n');
return 0;
}
Copy link
Member

@justinmk justinmk May 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this probably isn't the right approach. maybe leave this for a separate PR.

headless mode should proceed through normal mode as usual, we can't assume that it should exit here. E.g. some clients may want to connect while nvim --headless runs as a server. Nvim should exit only if :q command (or equivalent) was issued.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

I understand. I quit to touch this issue (I will focus only for “more”)

}

starting = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/nvim/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -2577,7 +2577,7 @@ static int do_more_prompt(int typed_char)
// 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
// and nothing was typed.
if (entered || (State == HITRETURN && typed_char == 0)) {
if (headless_mode || entered || (State == HITRETURN && typed_char == 0)) {
return false;
}
entered = true;
Expand Down
2 changes: 1 addition & 1 deletion test/functional/ex_cmds/digraphs_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local Screen = require('test.functional.ui.screen')
describe(':digraphs', function()
local screen
before_each(function()
clear()
clear{args_rm={'--headless'}}
screen = Screen.new(65, 8)
screen:set_default_attr_ids({
[1] = {bold = true, foreground = Screen.colors.Blue1},
Expand Down
4 changes: 3 additions & 1 deletion test/functional/ex_cmds/grep_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ local clear, feed_command, feed, ok, eval =
helpers.clear, helpers.feed_command, helpers.feed, helpers.ok, helpers.eval

describe(':grep', function()
before_each(clear)
before_each(function()
clear{args_rm={'--headless'}}
end)

it('does not hang on large input #2983', function()
if eval("executable('grep')") == 0 then
Expand Down