diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-06-19 21:04:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-19 21:04:08 +0200 |
commit | 74d19f685faf1ee2e96ddc54ae289ed5093f4e08 (patch) | |
tree | 4c9e0ceab087ba3610ff8d9308f14d912897a348 | |
parent | a10938ae318228330587c3f7bbf9178810931b0e (diff) | |
parent | 9625e9da75dbfd2e1925dabe28ec85583dc712b2 (diff) | |
download | rneovim-74d19f685faf1ee2e96ddc54ae289ed5093f4e08.tar.gz rneovim-74d19f685faf1ee2e96ddc54ae289ed5093f4e08.tar.bz2 rneovim-74d19f685faf1ee2e96ddc54ae289ed5093f4e08.zip |
Merge #8576 from justinmk/startup-empty-stdin
-rw-r--r-- | src/nvim/main.c | 6 | ||||
-rw-r--r-- | test/functional/core/startup_spec.lua | 12 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index ea43b93b30..6aed84aba5 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -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"); diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index ae5e2b4115..2a67453bce 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -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) |