From d44ed79ccc43b59fec9ef622f18f543ef1c73263 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 17 Jun 2018 23:05:28 +0200 Subject: startup: go to buffer 2 if stdin is empty If stdin is not a TTY we read it into buffer 1, as text. But if the stdin pipe is empty, Nvim was most likely invoked for some other reason. DWIM: select buffer 2 (if it exists). Example: echo file1 | xargs nvim closes #8560 closes #8561 ref https://github.com/equalsraf/neovim-qt/issues/417 --- test/functional/core/startup_spec.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index ae5e2b4115..5f18b902fb 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('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', + 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) -- cgit From 9625e9da75dbfd2e1925dabe28ec85583dc712b2 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 18 Jun 2018 18:48:28 +0200 Subject: 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 --- test/functional/core/startup_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') 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!', -- cgit