Skip to content

Commit 538da34

Browse files
ntdiarychrisbra
authored andcommitted
runtime(netrw): Fix reading UNC paths on windows
Problem: When Vim is launched with a UNC directory, netrw treats it as a relative path and compose it again. Solution: This is due to `exists("g:netrw_cygwin")` always being true. We can directly use `g:netrw_cygwin`. closes: #19015 Signed-off-by: tao <2471314@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent ffd5c52 commit 538da34

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

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

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
" 2025 Nov 13 by Vim Project don't wipe unnamed buffers #18740
1717
" 2025 Nov 18 by Vim Project use UNC paths when using scp and Windows paths #18764
1818
" 2025 Nov 28 by Vim Project fix undefined variable in *NetrwMenu #18829
19+
" 2025 Dec 26 by Vim Project fix use of g:netrw_cygwin #19015
1920
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
2021
" Permission is hereby granted to use and distribute this code,
2122
" with or without modifications, provided that this copyright
@@ -213,7 +214,7 @@ call s:NetrwInit("g:netrw_dirhistmax" , 10)
213214
call s:NetrwInit("g:netrw_fastbrowse" , 1)
214215
call s:NetrwInit("g:netrw_ftp_browse_reject", '^total\s\+\d\+$\|^Trying\s\+\d\+.*$\|^KERBEROS_V\d rejected\|^Security extensions not\|No such file\|: connect to address [0-9a-fA-F:]*: No route to host$')
215216
if !exists("g:netrw_ftp_list_cmd")
216-
if has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)
217+
if has("unix") || g:netrw_cygwin
217218
let g:netrw_ftp_list_cmd = "ls -lF"
218219
let g:netrw_ftp_timelist_cmd = "ls -tlF"
219220
let g:netrw_ftp_sizelist_cmd = "ls -slF"
@@ -320,7 +321,7 @@ call s:NetrwInit("g:netrw_menu" , 1)
320321
call s:NetrwInit("g:netrw_mkdir_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME mkdir")
321322
call s:NetrwInit("g:netrw_mousemaps" , (exists("+mouse") && &mouse =~# '[anh]'))
322323
call s:NetrwInit("g:netrw_retmap" , 0)
323-
if has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)
324+
if has("unix") || g:netrw_cygwin
324325
call s:NetrwInit("g:netrw_chgperm" , "chmod PERM FILENAME")
325326
elseif has("win32")
326327
call s:NetrwInit("g:netrw_chgperm" , "cacls FILENAME /e /p PERM")
@@ -442,7 +443,7 @@ function netrw#Explore(indx,dosplit,style,...)
442443

443444
" record current directory
444445
let curdir = simplify(b:netrw_curdir)
445-
if !exists("g:netrw_cygwin") && has("win32")
446+
if !g:netrw_cygwin && has("win32")
446447
let curdir= substitute(curdir,'\','/','g')
447448
endif
448449
let curfiledir = substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e')
@@ -520,7 +521,7 @@ function netrw#Explore(indx,dosplit,style,...)
520521
NetrwKeepj norm! 0
521522

522523
if a:0 > 0
523-
if a:1 =~ '^\~' && (has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin))
524+
if a:1 =~ '^\~' && (has("unix") || g:netrw_cygwin)
524525
let dirname= simplify(substitute(a:1,'\~',expand("$HOME"),''))
525526
elseif a:1 == '.'
526527
let dirname= simplify(exists("b:netrw_curdir")? b:netrw_curdir : getcwd())
@@ -3234,7 +3235,7 @@ function s:NetrwFile(fname)
32343235
let b:netrw_curdir= getcwd()
32353236
endif
32363237

3237-
if !exists("g:netrw_cygwin") && has("win32")
3238+
if !g:netrw_cygwin && has("win32")
32383239
if fname =~ '^\' || fname =~ '^\a:\'
32393240
" windows, but full path given
32403241
let ret= fname

0 commit comments

Comments
 (0)