Skip to content

Commit 384685f

Browse files
committed
patch 9.1.1914: runtime(netrw): wipes unnamed buffers
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 <[email protected]>
1 parent b811992 commit 384685f

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

runtime/pack/dist/opt/netrw/autoload/netrw.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
" 2025 Oct 26 by Vim Project fix parsing of remote user names #18611
1414
" 2025 Oct 27 by Vim Project align comment after #18611
1515
" 2025 Nov 01 by Vim Project fix NetrwChgPerm #18674
16+
" 2025 Nov 13 by Vim Project don't wipe unnamed buffers #18740
1617
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
1718
" Permission is hereby granted to use and distribute this code,
1819
" with or without modifications, provided that this copyright
@@ -8315,7 +8316,7 @@ function netrw#LocalBrowseCheck(dirname)
83158316
let ibuf = 1
83168317
let buflast = bufnr("$")
83178318
while ibuf <= buflast
8318-
if bufwinnr(ibuf) == -1 && isdirectory(s:NetrwFile(bufname(ibuf)))
8319+
if bufwinnr(ibuf) == -1 && !empty(bufname(ibuf)) && isdirectory(s:NetrwFile(bufname(ibuf)))
83198320
exe "sil! keepj keepalt ".ibuf."bw!"
83208321
endif
83218322
let ibuf= ibuf + 1

src/testdir/test_plugin_netrw.vim

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func Test_netrw_parse_ssh_config_entries()
104104
endfunction
105105

106106
"username containing special-chars"
107-
func Test_netrw_parse_special_char_user ()
107+
func Test_netrw_parse_special_char_user()
108108
call s:setup()
109109
let result = TestNetrwCaptureRemotePath('scp://user-01@localhost:2222/test.txt')
110110
call assert_equal(result.method, 'scp')
@@ -114,3 +114,19 @@ func Test_netrw_parse_special_char_user ()
114114
call assert_equal(result.path, 'test.txt')
115115
call s:cleanup()
116116
endfunction
117+
118+
func Test_netrw_wipe_empty_buffer_fastpath()
119+
let g:netrw_fastbrowse=0
120+
packadd netrw
121+
call setline(1, 'foobar')
122+
let bufnr = bufnr('%')
123+
tabnew
124+
Explore
125+
call search('README.txt', 'W')
126+
exe ":norm \<cr>"
127+
call assert_equal(4, bufnr('$'))
128+
call assert_true(bufexists(bufnr))
129+
bw
130+
131+
unlet! netrw_fastbrowse
132+
endfunction

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ static char *(features[]) =
729729

730730
static int included_patches[] =
731731
{ /* Add new patch number below this line */
732+
/**/
733+
1914,
732734
/**/
733735
1913,
734736
/**/

0 commit comments

Comments
 (0)