Merge pull request #41442 from zeertzjq/vim-9.2.0980

vim-patch:9.2.{0980,0993,0995}
This commit is contained in:
zeertzjq
2026-08-23 15:45:59 +08:00
committed by GitHub
2 changed files with 58 additions and 2 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 21
" 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
@@ -4494,7 +4494,7 @@ function s:NetrwHome()
if exists("g:netrw_mkdir")
call system(g:netrw_mkdir." ".s:ShellEscape(s:NetrwFile(home)))
else
call mkdir(home)
call mkdir(home, 'p')
endif
endif

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,55 @@ 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')
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')
let expected = netrw#fs#PathJoin(stdpath('state'), 'netrw')
if has('win32')
let expected = substitute(expected, '/', '\\', 'g')
endif
call assert_equal(expected, Test_NetrwHome())
else
" without the setting $MYVIMDIR is used
call assert_equal(vimdir, Test_NetrwHome())
endif
let g:netrw_home = dir
call assert_equal(dir, Test_NetrwHome())
call assert_true(isdirectory(dir))
let g:netrw_home = subdir
call assert_equal(subdir, Test_NetrwHome())
call assert_true(isdirectory(subdir))
" the value is expanded
let $NETRW_TEST_HOME = dir
let g:netrw_home = '$NETRW_TEST_HOME'
call assert_equal(dir, Test_NetrwHome())
call delete(dir, 'd')
call delete(vimdir, 'd')
call delete(subdir, 'd')
call delete(fnamemodify(subdir, ':h'), 'd')
unlet $NETRW_TEST_HOME
call setenv('MYVIMDIR', save_myvimdir)
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