" 2025 Dec 26 by Vim Project fix use of g:netrw_cygwin #19015
" 2026 Jan 19 by Vim Project do not create swapfiles #18854
" 2026 Feb 15 by Vim Project fix global variable initialization for MS-Windows #19287
+" 2026 Feb 21 by Vim Project better absolute path detection on MS-Windows #19477
" 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
endif
if !g:netrw_cygwin && has("win32")
- if fname =~ '^\' || fname =~ '^\a:\'
+ if isabsolutepath(fname)
" windows, but full path given
let ret= fname
else
endif
endfunction
-
" Test file copy operations via s:NetrwMarkFileMove()
function Test_NetrwMarkFileMove(source_dir, target_dir, marked_files) abort
" set up
bw
endfunction
+" Test how netrw fixes paths according with settings
+" (g:netrw_keepdir, g:netrw_cygwin, tree style ...)
+function Test_NetrwFile(fname) abort
+ return s:NetrwFile(a:fname)
+endfunction
+
" }}}
END
unlet! netrw_fastbrowse
endfunction
+" Test UNC paths on windows
+func Test_netrw_check_UNC_paths()
+ CheckMSWindows
+
+ let test_paths = [
+ \ '\\Server2\Share\Test\Foo.txt',
+ \ '//Server2/Share/Test/Foo.txt',
+ \ '\\Server2\Share\Test\',
+ \ '//Server2/Share/Test/',
+ \ '\\wsl.localhost\Ubuntu\home\user\_vimrc',
+ \ '//wsl.localhost/Ubuntu/home/user/_vimrc',
+ \ '\\wsl.localhost\Ubuntu\home\user',
+ \ '//wsl.localhost/Ubuntu/home/user']
+
+ " The paths must be interpreted as absolute ones
+ for path in test_paths
+ call assert_equal(
+ \ path,
+ \ Test_NetrwFile(path),
+ \ $"UNC path: {path} missinterpreted")
+ endfor
+
+endfunction
+
" ---------------------------------
" Testing file management functions
" ---------------------------------