From bf7d308000f90fae6b69b7f34a3e25e643017819 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Aug 2026 08:38:38 +0800 Subject: [PATCH] vim-patch:9.2.0980: runtime(netrw): prioritize g:netrw_home on Neovim Problem: runtime(netrw): g:netrw_home not respected on Neovim Solution: prioritize g:netrw_home for bookmarks and history directory setting, add tests (J. Paulo Seibt) related: neovim/neovim@5a78c5b closes: vim/vim#21091 https://github.com/vim/vim/commit/4be03620b305282270e41643e5e860f95efa8f07 Co-authored-by: J. Paulo Seibt --- .../pack/dist/opt/netrw/autoload/netrw.vim | 2 +- test/old/testdir/test_plugin_netrw.vim | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/runtime/pack/dist/opt/netrw/autoload/netrw.vim b/runtime/pack/dist/opt/netrw/autoload/netrw.vim index cabcd0c925..c1f7b55c85 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 " Maintainer: This runtime file is looking for a new maintainer. -" Last Change: 2026 Jul 23 +" Last Change: 2026 Aug 19 " 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 diff --git a/test/old/testdir/test_plugin_netrw.vim b/test/old/testdir/test_plugin_netrw.vim index b6a18ff418..0a5e594ad8 100644 --- a/test/old/testdir/test_plugin_netrw.vim +++ b/test/old/testdir/test_plugin_netrw.vim @@ -196,6 +196,11 @@ function Test_NetrwMarkFile_match_pattern_rebuild() bw endfunction + +" Test the "home" directory used for bookmarks and history +function Test_NetrwHome() abort + return s:NetrwHome() +endfunction " }}} END @@ -921,4 +926,39 @@ func Test_netrw_open_no_dir_arg() bw! endfunc +func Test_netrw_home_setting() + let save_home = get(g:, 'netrw_home', '') + let dir = fnamemodify('XnetrwHome', ':p:h') + if has('win32') + let dir = substitute(dir, '/', '\\', 'g') + endif + + if has('nvim') + unlet! g:netrw_home + call assert_equal(netrw#fs#PathJoin(stdpath('state'), 'netrw'), Test_NetrwHome()) + endif + + let g:netrw_home = dir + call assert_equal(dir, Test_NetrwHome()) + call assert_true(isdirectory(dir)) + + " the value is expanded + let $NETRW_TEST_HOME = dir + let g:netrw_home = '$NETRW_TEST_HOME' + call assert_equal(dir, Test_NetrwHome()) + + " without the setting $MYVIMDIR is used + unlet g:netrw_home + let $MYVIMDIR = dir + call assert_equal(dir, Test_NetrwHome()) + + call delete(dir, 'd') + let $NETRW_TEST_HOME = '' + if empty(save_home) + unlet! g:netrw_home + else + let g:netrw_home = save_home + endif +endfunc + " vim:ts=8 sts=2 sw=2 et