From 9a4711dec78a1126e5697cf80e82fbdcc55c1510 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Aug 2026 08:39:38 +0800 Subject: [PATCH] vim-patch:9.2.0995: tests: no check that g:netrw_home has higher priority than $MYVIMDIR Problem: No check that g:netrw_home has higher priority than $MYVIMDIR. Solution: Set $MYVIMDIR to a different directory at the start of the test function. Also, s:NetrwHome() checks has('nvim') before exists('$MYVIMDIR'). This ordering does make sense as Nvim's docs have no mention of $MYVIMDIR. Match that in the test. closes: vim/vim#21117 https://github.com/vim/vim/commit/b3526a91b82779c2d9e2f3ca330039143cc36862 --- test/old/testdir/test_plugin_netrw.vim | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/old/testdir/test_plugin_netrw.vim b/test/old/testdir/test_plugin_netrw.vim index 514afceb85..e5594c82e5 100644 --- a/test/old/testdir/test_plugin_netrw.vim +++ b/test/old/testdir/test_plugin_netrw.vim @@ -929,15 +929,22 @@ endfunc func Test_netrw_home_setting() let save_home = get(g:, 'netrw_home', '') let dir = fnamemodify('XnetrwHome', ':p') + let vimdir = fnamemodify('XvimDir', ':p') let subdir = fnamemodify('XnetrwHomeParent/XnetrwHome', ':p') if has('win32') let dir = substitute(dir, '/', '\\', 'g') + let vimdir = substitute(vimdir, '/', '\\', 'g') let subdir = substitute(subdir, '/', '\\', 'g') endif - + let save_myvimdir = getenv('MYVIMDIR') + let $MYVIMDIR = vimdir + + unlet! g:netrw_home if has('nvim') - unlet! g:netrw_home call assert_equal(netrw#fs#PathJoin(stdpath('state'), 'netrw'), Test_NetrwHome()) + else + " without the setting $MYVIMDIR is used + call assert_equal(vimdir, Test_NetrwHome()) endif let g:netrw_home = dir @@ -953,15 +960,12 @@ func Test_netrw_home_setting() 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') + call delete(vimdir, 'd') call delete(subdir, 'd') call delete(fnamemodify(subdir, ':h'), 'd') - let $NETRW_TEST_HOME = '' + unlet $NETRW_TEST_HOME + call setenv('MYVIMDIR', save_myvimdir) if empty(save_home) unlet! g:netrw_home else