From 19fff0e0bed2a77c8f8d27070cc12084bce24000 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 31 Mar 2026 09:13:54 +0800 Subject: [PATCH] vim-patch:9.2.0232: fileinfo not shown after :bd of last listed buffer (#38453) Problem: fileinfo not shown after :bd of last listed buffer (memeplex) Solution: Set need_fileinfo to true in empty_curbuf() (Hirohito Higashi) When deleting the last listed buffer with :bd, the new empty buffer's file info (e.g. "[No Name]" --No lines in buffer--) was not displayed. do_ecmd() only calls fileinfo() for existing buffers (oldbuf), not for newly created empty buffers. Set need_fileinfo in empty_curbuf() so the file info is displayed after redraw. fixes: vim/vim#548 closes: vim/vim#19802 https://github.com/vim/vim/commit/3d472d86753c451ce6914f70161ffc40ee37ea96 Co-authored-by: Hirohito Higashi Co-authored-by: Claude Opus 4.6 (1M context) --- src/nvim/buffer.c | 3 +++ test/functional/legacy/messages_spec.lua | 29 ++++++++++++++++++++++++ test/old/testdir/test_messages.vim | 24 ++++++++++++++++++++ 3 files changed, 56 insertions(+) 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