Skip to content

Commit ee1a24b

Browse files
saccarosiumchrisbra
authored andcommitted
runtime(netrw): fix s:NetrwHome() regression
If $MYVIMDIR is unset netrw creates a directory called '$MYVIMDIR' in the current directory fixes: #16609 Signed-off-by: Christian Brabandt <[email protected]>
1 parent 44c1c04 commit ee1a24b

1 file changed

Lines changed: 22 additions & 20 deletions

File tree

  • runtime/pack/dist/opt/netrw/autoload

runtime/pack/dist/opt/netrw/autoload/netrw.vim

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5297,30 +5297,32 @@ endfun
52975297
" ---------------------------------------------------------------------
52985298
" s:NetrwHome: this function determines a "home" for saving bookmarks and history {{{2
52995299
function! s:NetrwHome()
5300-
if has('nvim')
5301-
let home = netrw#own#PathJoin(stdpath('state'), 'netrw')
5302-
elseif exists("g:netrw_home")
5303-
let home = expand(g:netrw_home)
5304-
else
5305-
let home = expand("$MYVIMDIR")->substitute("/$", "", "")
5306-
endif
5307-
5308-
" insure that the home directory exists
5309-
if g:netrw_dirhistmax > 0 && !isdirectory(s:NetrwFile(home))
5310-
if exists("g:netrw_mkdir")
5311-
call system(g:netrw_mkdir." ".s:ShellEscape(s:NetrwFile(home)))
5300+
if has('nvim')
5301+
let home = netrw#own#PathJoin(stdpath('state'), 'netrw')
5302+
elseif exists('g:netrw_home')
5303+
let home = expand(g:netrw_home)
5304+
elseif exists('$MYVIMDIR')
5305+
let home = expand('$MYVIMDIR')->substitute('/$', '', '')
53125306
else
5313-
call mkdir(home)
5307+
let home = netrw#own#PathJoin(expand('~'), '.vim')
53145308
endif
5315-
endif
53165309

5317-
" Normalize directory if on Windows
5318-
if has("win32")
5319-
let home = substitute(home, '/', '\\', 'g')
5320-
endif
5310+
" insure that the home directory exists
5311+
if g:netrw_dirhistmax > 0 && !isdirectory(s:NetrwFile(home))
5312+
if exists("g:netrw_mkdir")
5313+
call system(g:netrw_mkdir." ".s:ShellEscape(s:NetrwFile(home)))
5314+
else
5315+
call mkdir(home)
5316+
endif
5317+
endif
5318+
5319+
" Normalize directory if on Windows
5320+
if has("win32")
5321+
let home = substitute(home, '/', '\\', 'g')
5322+
endif
53215323

5322-
let g:netrw_home = home
5323-
return home
5324+
let g:netrw_home = home
5325+
return home
53245326
endfunction
53255327

53265328
" ---------------------------------------------------------------------

0 commit comments

Comments
 (0)