Commit: patch 9.2.0464: runtime(netrw): bookmarking directory uses current dir

2 views
Skip to first unread message

Christian Brabandt

unread,
May 10, 2026, 1:00:15 PM (10 days ago) May 10
to vim...@googlegroups.com
patch 9.2.0464: runtime(netrw): bookmarking directory uses current dir

Commit: https://github.com/vim/vim/commit/ec76ac620b870abb4ccc9298250691e88a2adb29
Author: J. Paulo Seibt <jps...@gmail.com>
Date: Sun May 10 16:50:02 2026 +0000

patch 9.2.0464: runtime(netrw): bookmarking directory uses current dir

Problem: runtime(netrw): bookmarking directory uses current dir
Solution: Correctly handle netrw actual directory (J. Paulo Seibt)

fixes: #10481
closes: #20169

Signed-off-by: J. Paulo Seibt <jps...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/pack/dist/opt/netrw/autoload/netrw.vim b/runtime/pack/dist/opt/netrw/autoload/netrw.vim
index 90fd70472..7d73af8fa 100644
--- a/runtime/pack/dist/opt/netrw/autoload/netrw.vim
+++ b/runtime/pack/dist/opt/netrw/autoload/netrw.vim
@@ -1,7 +1,7 @@
" Creator: Charles E Campbell
" Previous Maintainer: Luca Saccarola <github...@aleeas.com>
" Maintainer: This runtime file is looking for a new maintainer.
-" Last Change: 2026 May 05
+" Last Change: 2026 May 10
" 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
@@ -8989,11 +8989,10 @@ function s:MakeBookmark(fname)
if index(g:netrw_bookmarklist,a:fname) == -1
" curdir not currently in g:netrw_bookmarklist, so include it
if isdirectory(s:NetrwFile(a:fname)) && a:fname !~ '/$'
- call add(g:netrw_bookmarklist,a:fname.'/')
- elseif a:fname !~ '/'
- call add(g:netrw_bookmarklist,getcwd()."/".a:fname)
+ " Directory without a trailing slash
+ call add(g:netrw_bookmarklist, s:NetrwFile(a:fname) . '/')
else
- call add(g:netrw_bookmarklist,a:fname)
+ call add(g:netrw_bookmarklist, s:NetrwFile(a:fname))
endif
call sort(g:netrw_bookmarklist)
endif
diff --git a/src/testdir/test_plugin_netrw.vim b/src/testdir/test_plugin_netrw.vim
index b66bb4a72..5a86c29b7 100644
--- a/src/testdir/test_plugin_netrw.vim
+++ b/src/testdir/test_plugin_netrw.vim
@@ -165,6 +165,13 @@ function Test_NetrwUnMarkFile()
" wipe out the test buffer
bw
endfunction
+
+function Test_MakeBookmark(netrw_curdir, fname)
+ new
+ let b:netrw_curdir = a:netrw_curdir
+ call s:MakeBookmark(a:fname)
+ bw
+endfunction
" }}}
END

@@ -676,4 +683,38 @@ func Test_netrw_unmark_all()
call Test_NetrwUnMarkFile()
endfunc

+" Creating a bookmark from a marked file should use b:netrw_curdir as head directory
+func Test_netrw_bookmark_marked_file()
+ let save_keepdir = g:netrw_keepdir
+ let save_workdir = getcwd()
+ let save_bookmarklist = exists('g:netrw_bookmarklist') ? g:netrw_bookmarklist : v:null
+
+ " Make sure Vim's working directory diverge from Netrw's
+ let g:netrw_keepdir = 1
+ let g:netrw_bookmarklist = []
+ let test_workdir = 'Xtest_workdir'
+ let test_netrw_curdir = test_workdir . '/Xtest_netrw_curdir'
+ call mkdir(test_netrw_curdir, 'p')
+ call writefile([], test_netrw_curdir . '/test_file')
+
+ execute 'cd ' . test_workdir
+ call Test_MakeBookmark(test_netrw_curdir, 'test_file')
+
+ call assert_equal(1, len(g:netrw_bookmarklist))
+ call assert_match(test_netrw_curdir . '/test_file', g:netrw_bookmarklist[0])
+
+ " Tear down
+ execute 'cd ' . save_workdir
+ call delete(test_workdir, 'rf')
+
+ let g:netrw_keepdir = save_keepdir
+ if save_bookmarklist is v:null
+ unlet g:netrw_bookmarklist
+ else
+ let g:netrw_bookmarklist = save_bookmarklist
+ endif
+
+ bw!
+endfunc
+
" vim:ts=8 sts=2 sw=2 et
diff --git a/src/version.c b/src/version.c
index 1e9a692ea..339bc4459 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 464,
/**/
463,
/**/
Reply all
Reply to author
Forward
0 new messages