diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index c22d9356f4..300e4c4ce2 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1253,6 +1253,9 @@ static int empty_curbuf(bool close_others, int forceit, int action) if (!close_others) { need_fileinfo = false; + } else if (retval == OK && !shortmess(SHM_FILEINFO)) { + // do_ecmd() does not display file info for a new empty buffer. + need_fileinfo = true; } return retval; diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index 6d99800a5e..e02dd87bc1 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -887,4 +887,33 @@ describe('messages', function() 3 lines filtered | ]]) end) + + -- oldtest: Test_fileinfo_after_last_bd() + it('fileinfo is shown after :bd on last listed buffer', function() + screen = Screen.new(50, 10) + exec([[ + set shortmess-=F + edit xxx + edit yyy + ]]) + screen:expect([[ + ^ | + {1:~ }|*8 + "yyy" [New] | + ]]) + + command('bd') + screen:expect([[ + ^ | + {1:~ }|*8 + "xxx" [New] --No lines in buffer-- | + ]]) + + command('bd') + screen:expect([[ + ^ | + {1:~ }|*8 + "[No Name]" --No lines in buffer-- | + ]]) + end) end) diff --git a/test/old/testdir/test_messages.vim b/test/old/testdir/test_messages.vim index abe25fbd22..26497e5c32 100644 --- a/test/old/testdir/test_messages.vim +++ b/test/old/testdir/test_messages.vim @@ -756,4 +756,28 @@ func Test_long_formatprg_no_hit_enter() call StopVimInTerminal(buf) endfunc +" Test that fileinfo is shown after deleting the last listed buffer with :bd +func Test_fileinfo_after_last_bd() + CheckRunVimInTerminal + + let content =<< trim END + set shortmess-=F + edit xxx + edit yyy + END + + call writefile(content, 'Xtest_fileinfo_last_bd', 'D') + let buf = RunVimInTerminal('-S Xtest_fileinfo_last_bd', #{rows: 10}) + call WaitForAssert({-> assert_match('^"yyy" \[New\]', term_getline(buf, 10))}) + + call term_sendkeys(buf, ":bd\") + call WaitForAssert({-> assert_match('^"xxx" \[New\]', term_getline(buf, 10))}) + + call term_sendkeys(buf, ":bd\") + call WaitForAssert({-> assert_match('^\"\[No Name\]\" --No lines in buffer--', term_getline(buf, 10))}) + + " clean up + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab