Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startup: go to buffer 2 if stdin is empty #8576

Merged
merged 2 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions src/nvim/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,12 @@ static void read_stdin(void)
int save_msg_didany = msg_didany;
set_buflisted(true);
(void)open_buffer(true, NULL, 0); // create memfile and read file
if (BUFEMPTY() && curbuf->b_next != NULL) {
// stdin was empty, go to buffer 2 (e.g. "echo file1 | xargs nvim"). #8561
do_cmdline_cmd("silent! bnext");
// Delete the empty stdin buffer.
do_cmdline_cmd("bwipeout 1");
}
no_wait_return = false;
msg_didany = save_msg_didany;
TIME_MSG("reading stdin");
Expand Down
12 changes: 12 additions & 0 deletions test/functional/core/startup_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ describe('startup', function()
{ 'ohyeah', '' }))
end)

it('if stdin is empty: selects buffer 2, deletes buffer 1 #8561', function()
eq('\r\n 2 %a "file1" line 0\r\n 3 "file2" line 0',
funcs.system({nvim_prog, '-n', '-u', 'NONE', '-i', 'NONE', '--headless',
'+ls!',
'+qall!',
'-',
'file1',
'file2',
},
{ '' }))
end)

it('-e/-E interactive #7679', function()
clear('-e')
local screen = Screen.new(25, 3)
Expand Down