diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-06-18 18:48:28 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-06-18 21:51:42 +0200 |
commit | 9625e9da75dbfd2e1925dabe28ec85583dc712b2 (patch) | |
tree | 43069300f43c1d2a3c41fc6f51c29b779c927d28 | |
parent | d44ed79ccc43b59fec9ef622f18f543ef1c73263 (diff) | |
download | rneovim-9625e9da75dbfd2e1925dabe28ec85583dc712b2.tar.gz rneovim-9625e9da75dbfd2e1925dabe28ec85583dc712b2.tar.bz2 rneovim-9625e9da75dbfd2e1925dabe28ec85583dc712b2.zip |
startup: delete empty stdin buffer if other files were opened
DWIM: avoid empty buffer 1 when stdin was empty. If other files were
specified at startup, we assume that stdin is only accidentally
not-a-TTY: user did not intend to send text from it.
ref #8560
ref #8561
-rw-r--r-- | src/nvim/main.c | 6 | ||||
-rw-r--r-- | test/functional/core/startup_spec.lua | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index 9c9be4aa02..6aed84aba5 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1412,9 +1412,9 @@ static void read_stdin(void) (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 - msg_silent++; - do_buffer(DOBUF_GOTO, DOBUF_FIRST, FORWARD, curbuf->b_next->handle, 0); - msg_silent--; + do_cmdline_cmd("silent! bnext"); + // Delete the empty stdin buffer. + do_cmdline_cmd("bwipeout 1"); } no_wait_return = false; msg_didany = save_msg_didany; diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 5f18b902fb..2a67453bce 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -122,8 +122,8 @@ describe('startup', function() { 'ohyeah', '' })) end) - it('goes to buffer 2 if stdin is empty #8561', function() - eq('\r\n 1u# "[No Name]" line 1\r\n 2 %a "file1" line 0\r\n 3 "file2" line 0', + 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!', |