mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 23:18:33 +00:00
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
This commit is contained in:
@@ -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
|
||||
msg_silent++;
|
||||
do_buffer(DOBUF_GOTO, DOBUF_FIRST, FORWARD, curbuf->b_next->handle, 0);
|
||||
msg_silent--;
|
||||
}
|
||||
no_wait_return = false;
|
||||
msg_didany = save_msg_didany;
|
||||
TIME_MSG("reading stdin");
|
||||
|
Reference in New Issue
Block a user