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

4be03620b3

Co-authored-by: J. Paulo Seibt <jpseibt@gmail.com>
This commit is contained in:
zeertzjq
2026-08-23 08:38:38 +08:00
parent d3b4f562a6
commit bf7d308000
2 changed files with 41 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
" Creator: Charles E Campbell
" Previous Maintainer: Luca Saccarola <github.e41mv@aleeas.com>
" 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

View File

@@ -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