fix(startup): file buf is lost if stdin is empty and "-" is last #35402

Problem:
Running `echo dummy | nvim file1 file2` closes the file1 buffer if
file1 doesn't exist.

Solution:
Logic changed in 43e8ec9 such that stdin buffer may now be created *after*
file args. Handle that case.
This commit is contained in:
Cameron Ring
2025-08-20 20:34:49 -07:00
committed by GitHub
parent a8dad46e1c
commit 30dae87de4
2 changed files with 47 additions and 5 deletions

View File

@@ -534,6 +534,26 @@ describe('startup', function()
)
end)
it('if stdin is empty and - is last: selects buffer 1, deletes buffer 3 #35269', function()
eq(
'\r\n 1 %a "file1" line 0\r\n 2 #h "file2" line 1',
fn.system({
nvim_prog,
'-n',
'-u',
'NONE',
'-i',
'NONE',
'--headless',
'+ls!',
'+qall!',
'file1',
'file2',
'-',
}, { '' })
)
end)
it('stdin with -es/-Es #7679', function()
local input = { 'append', 'line1', 'line2', '.', '%print', '' }
local inputstr = table.concat(input, '\n')