mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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
This commit is contained in:
parent
d44ed79ccc
commit
9625e9da75
@ -1412,9 +1412,9 @@ static void read_stdin(void)
|
|||||||
(void)open_buffer(true, NULL, 0); // create memfile and read file
|
(void)open_buffer(true, NULL, 0); // create memfile and read file
|
||||||
if (BUFEMPTY() && curbuf->b_next != NULL) {
|
if (BUFEMPTY() && curbuf->b_next != NULL) {
|
||||||
// stdin was empty, go to buffer 2 (e.g. "echo file1 | xargs nvim"). #8561
|
// stdin was empty, go to buffer 2 (e.g. "echo file1 | xargs nvim"). #8561
|
||||||
msg_silent++;
|
do_cmdline_cmd("silent! bnext");
|
||||||
do_buffer(DOBUF_GOTO, DOBUF_FIRST, FORWARD, curbuf->b_next->handle, 0);
|
// Delete the empty stdin buffer.
|
||||||
msg_silent--;
|
do_cmdline_cmd("bwipeout 1");
|
||||||
}
|
}
|
||||||
no_wait_return = false;
|
no_wait_return = false;
|
||||||
msg_didany = save_msg_didany;
|
msg_didany = save_msg_didany;
|
||||||
|
@ -122,8 +122,8 @@ describe('startup', function()
|
|||||||
{ 'ohyeah', '' }))
|
{ 'ohyeah', '' }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('goes to buffer 2 if stdin is empty #8561', function()
|
it('if stdin is empty: selects buffer 2, deletes buffer 1 #8561', function()
|
||||||
eq('\r\n 1u# "[No Name]" line 1\r\n 2 %a "file1" line 0\r\n 3 "file2" line 0',
|
eq('\r\n 2 %a "file1" line 0\r\n 3 "file2" line 0',
|
||||||
funcs.system({nvim_prog, '-n', '-u', 'NONE', '-i', 'NONE', '--headless',
|
funcs.system({nvim_prog, '-n', '-u', 'NONE', '-i', 'NONE', '--headless',
|
||||||
'+ls!',
|
'+ls!',
|
||||||
'+qall!',
|
'+qall!',
|
||||||
|
Loading…
Reference in New Issue
Block a user