]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1914: runtime(netrw): wipes unnamed buffers v9.1.1914
authorChristian Brabandt <cb@256bit.org>
Thu, 13 Nov 2025 21:11:51 +0000 (21:11 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 13 Nov 2025 21:11:51 +0000 (21:11 +0000)
Problem:  runtime(netrw): LocalBrowseCheck() wipes unnamed buffers when
          g:netrw_fastbrowse=0 (Carlos Falgueras GarcĂ­a)
Solution: Check that bufname() is not empty

fixes: #18740
closes: #18741

Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/pack/dist/opt/netrw/autoload/netrw.vim
src/testdir/test_plugin_netrw.vim
src/version.c

index dcf8a365f266ff6400e7e9fadb282c969a61c2f1..3b80a4a3141fd5497c4048cce1cdf7dd0e54f07a 100644 (file)
@@ -13,6 +13,7 @@
 " 2025 Oct 26 by Vim Project fix parsing of remote user names #18611
 " 2025 Oct 27 by Vim Project align comment after #18611
 " 2025 Nov 01 by Vim Project fix NetrwChgPerm #18674
+" 2025 Nov 13 by Vim Project don't wipe unnamed buffers #18740
 " Copyright:  Copyright (C) 2016 Charles E. Campbell {{{1
 "             Permission is hereby granted to use and distribute this code,
 "             with or without modifications, provided that this copyright
@@ -8315,7 +8316,7 @@ function netrw#LocalBrowseCheck(dirname)
         let ibuf    = 1
         let buflast = bufnr("$")
         while ibuf <= buflast
-            if bufwinnr(ibuf) == -1 && isdirectory(s:NetrwFile(bufname(ibuf)))
+            if bufwinnr(ibuf) == -1 && !empty(bufname(ibuf)) && isdirectory(s:NetrwFile(bufname(ibuf)))
                 exe "sil! keepj keepalt ".ibuf."bw!"
             endif
             let ibuf= ibuf + 1
index 750a7d1d9222d70d0058315b9f27e5d798e977fa..ab11c3da244f80a75286669e733e6187903a3ba9 100644 (file)
@@ -104,7 +104,7 @@ func Test_netrw_parse_ssh_config_entries()
 endfunction
 
 "username containing special-chars"
-func Test_netrw_parse_special_char_user ()
+func Test_netrw_parse_special_char_user()
   call s:setup()
   let result = TestNetrwCaptureRemotePath('scp://user-01@localhost:2222/test.txt')
   call assert_equal(result.method, 'scp')
@@ -114,3 +114,19 @@ func Test_netrw_parse_special_char_user ()
   call assert_equal(result.path, 'test.txt')
   call s:cleanup()
 endfunction
+
+func Test_netrw_wipe_empty_buffer_fastpath()
+  let g:netrw_fastbrowse=0
+  packadd netrw
+  call setline(1, 'foobar')
+  let  bufnr = bufnr('%')
+  tabnew
+  Explore
+  call search('README.txt', 'W')
+  exe ":norm \<cr>"
+  call assert_equal(4, bufnr('$'))
+  call assert_true(bufexists(bufnr))
+  bw
+
+  unlet! netrw_fastbrowse
+endfunction
index 5065b15ba1ddbcec71d67a974615fd6506d9b31d..3dfd121c9870c314843b57c6231e07c6f94ea858 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1914,
 /**/
     1913,
 /**/