From 84308e47465910ce2608486f03f335b7e91e88c4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 29 Jun 2026 06:36:07 +0800 Subject: [PATCH] vim-patch:48474e6: runtime(netrw): Use consistent forward slashes fixes: vim/vim#20636 closes: vim/vim#20663 https://github.com/vim/vim/commit/48474e63704b6d5ae2f491ef320d33ef74e87357 Co-authored-by: Christian Brabandt --- .../pack/dist/opt/netrw/autoload/netrw.vim | 23 +++++++++++++------ test/old/testdir/test_plugin_netrw.vim | 9 ++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/runtime/pack/dist/opt/netrw/autoload/netrw.vim b/runtime/pack/dist/opt/netrw/autoload/netrw.vim index 02efbc5d24..69f145cec3 100644 --- a/runtime/pack/dist/opt/netrw/autoload/netrw.vim +++ b/runtime/pack/dist/opt/netrw/autoload/netrw.vim @@ -1,7 +1,7 @@ " Creator: Charles E Campbell " Previous Maintainer: Luca Saccarola " Maintainer: This runtime file is looking for a new maintainer. -" Last Change: 2026 Jun 16 +" Last Change: 2026 Jun 28 " 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 @@ -418,7 +418,7 @@ endif " == 6: Texplore function netrw#Explore(indx,dosplit,style,...) if !exists("b:netrw_curdir") - let b:netrw_curdir= getcwd() + let b:netrw_curdir= netrw#fs#Cwd(0) endif " record current file for Rexplore's benefit @@ -525,6 +525,10 @@ function netrw#Explore(indx,dosplit,style,...) call s:NetrwClearExplore() return endif + " Win32: Use forward slashes + if !g:netrw_cygwin && has("win32") + let dirname= substitute(dirname,'\','/','g') + endif if dirname =~ '\.\./\=$' let dirname= simplify(fnamemodify(dirname,':p:h')) @@ -568,14 +572,11 @@ function netrw#Explore(indx,dosplit,style,...) if starpat == 0 && a:indx >= 0 " [Explore Hexplore Vexplore Sexplore] [dirname] - if dirname == "" - let dirname= curfiledir - endif if dirname =~# '^scp://' || dirname =~ '^ftp://' call netrw#Nread(2,dirname) else if dirname == "" - let dirname= getcwd() + let dirname= netrw#fs#Cwd(0) elseif has("win32") && !g:netrw_cygwin " Windows : check for a drive specifier, or else for a remote share name ('\\Foo' or '//Foo', " depending on whether backslashes have been converted to forward slashes by earlier code). @@ -4987,7 +4988,7 @@ function s:NetrwMaps(islocal) nno NetrwSLeftmouse :exec "norm! \leftmouse>"call NetrwSLeftmouse(1) nno NetrwSLeftdrag :exec "norm! \leftmouse>"call NetrwSLeftdrag(1) nmap Netrw2Leftmouse - - exe 'nnoremap :exec "norm! \leftmouse>"call NetrwLocalRm("'.mapsafecurdir.'")' + exe 'nnoremap :exec "norm! \leftmouse>"call NetrwLocalRm("'.mapsafecurdir.'")' exe 'vnoremap :exec "norm! \leftmouse>"call NetrwLocalRm("'.mapsafecurdir.'")' endif exe 'nnoremap :call NetrwLocalRm("'.mapsafecurdir.'")' @@ -8683,7 +8684,15 @@ function s:NetrwLocalRename(path) range endif NetrwKeepj norm! 0 + if exists('+shellslash') && !&ssl + let reset_ssl = 1 + set ssl + endif + " Consistently use / as directory separator let oldname= netrw#fs#ComposePath(a:path,curword) + if reset_ssl + set nossl + endif call inputsave() let newname= input("Moving ".oldname." to : ",substitute(oldname,'/*$','','e')) diff --git a/test/old/testdir/test_plugin_netrw.vim b/test/old/testdir/test_plugin_netrw.vim index e847f8af90..0e9f43165a 100644 --- a/test/old/testdir/test_plugin_netrw.vim +++ b/test/old/testdir/test_plugin_netrw.vim @@ -876,4 +876,13 @@ func Test_netrw_local_rm_injection() endtry endfunc +func Test_netrw_forward_slashes() + Explore + call assert_notmatch('\\', b:netrw_curdir) + bw! + Explore . + call assert_notmatch('\\', b:netrw_curdir) + bw! +endfunc + " vim:ts=8 sts=2 sw=2 et