Skip to content

Commit 8337d77

Browse files
MiguelBarrochrisbra
authored andcommitted
runtime(netrw): MS-Windows: fix netrw not being able to navigate to parent folder
fixes: #18421 closes: #18464 Signed-off-by: Miguel Barro <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 014c731 commit 8337d77

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
" 2025 Sep 11 by Vim Project only keep cursor position in tree mode #18275
1010
" 2025 Sep 17 by Vim Project tighten the regex to handle remote compressed archives #18318
1111
" 2025 Sep 18 by Vim Project 'equalalways' not always respected #18358
12+
" 2025 Oct 01 by Vim Project fix navigate to parent folder #18464
1213
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
1314
" Permission is hereby granted to use and distribute this code,
1415
" with or without modifications, provided that this copyright
@@ -3950,7 +3951,8 @@ function s:NetrwBrowseChgDir(islocal, newdir, cursor, ...)
39503951
" NetrwBrowseChgDir: go up one directory {{{3
39513952
" --------------------------------------
39523953

3953-
let dirname = netrw#fs#Dirname(dirname)
3954+
" The following regexps expect '/' as path separator
3955+
let dirname = substitute(netrw#fs#AbsPath(dirname), '\\', '/', 'ge') . '/'
39543956

39553957
if w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict")
39563958
" force a refresh

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
" THESE FUNCTIONS DON'T COMMIT TO ANY BACKWARDS COMPATIBILITY. SO CHANGES AND
33
" BREAKAGES IF USED OUTSIDE OF NETRW.VIM ARE EXPECTED.
44

5-
let s:slash = !exists('+shellslash') || &shellslash ? '/' : '\'
65

76
" netrw#fs#PathJoin: Appends a new part to a path taking different systems into consideration {{{
87

98
function! netrw#fs#PathJoin(...)
9+
const slash = !exists('+shellslash') || &shellslash ? '/' : '\'
1010
let path = ""
1111

1212
for arg in a:000
1313
if empty(path)
1414
let path = arg
1515
else
16-
let path .= s:slash . arg
16+
let path .= slash . arg
1717
endif
1818
endfor
1919

@@ -73,22 +73,14 @@ endfunction
7373
" netrw#fs#AbsPath: returns the full path to a directory and/or file {{{
7474

7575
function! netrw#fs#AbsPath(path)
76-
let path = a:path->substitute(s:slash . '$', '', 'e')
76+
let path = a:path->substitute('[\/]$', '', 'e')
7777

7878
" Nothing to do
7979
if isabsolutepath(path)
8080
return path
8181
endif
8282

83-
return path->fnamemodify(':p')->substitute(s:slash . '$', '', 'e')
84-
endfunction
85-
86-
" }}}
87-
" netrw#fs#Dirname: {{{
88-
89-
function netrw#fs#Dirname(path)
90-
" Keep a slash as directory recognition pattern
91-
return netrw#fs#AbsPath(a:path) . s:slash
83+
return path->fnamemodify(':p')->substitute('[\/]$', '', 'e')
9284
endfunction
9385

9486
" }}}

0 commit comments

Comments
 (0)