]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0037: netrw: need better tests for absolute paths v9.2.0037
authorMiguel Barro <miguel.barro@live.com>
Sat, 21 Feb 2026 10:23:36 +0000 (10:23 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 21 Feb 2026 10:26:21 +0000 (10:26 +0000)
Problem:  netrw: need better tests for absolute paths
Solution: Use absolutepath(), instead of regex test (Miguel Barro).

closes: #19477

Signed-off-by: Guybrush <miguel.barro@live.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/pack/dist/opt/netrw/autoload/netrw.vim
src/testdir/test_plugin_netrw.vim
src/version.c

index 4f0d7b3b5fbcdc1893874b60ba3959af0f759ccd..51e05f2b1f6e81ba168fdd73826eb3cfa1ccd445 100644 (file)
@@ -19,6 +19,7 @@
 " 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
@@ -3239,7 +3240,7 @@ function s:NetrwFile(fname)
         endif
 
         if !g:netrw_cygwin && has("win32")
-            if fname =~ '^\' || fname =~ '^\a:\'
+            if isabsolutepath(fname)
                 " windows, but full path given
                 let ret= fname
             else
index 09109b4712e8bec8da95670623bbdf0a07709d79..23a060227d4fe861b363b7f90981455b4505f0b7 100644 (file)
@@ -113,7 +113,6 @@ function Test_NetrwMarkFileCopy_SameDir(dir = $HOME, symlink = 0) abort
     endif
 endfunction
 
-
 " Test file copy operations via s:NetrwMarkFileMove()
 function Test_NetrwMarkFileMove(source_dir, target_dir, marked_files) abort
     " set up
@@ -128,6 +127,12 @@ function Test_NetrwMarkFileMove(source_dir, target_dir, marked_files) abort
     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
 
@@ -303,6 +308,30 @@ func Test_netrw_wipe_empty_buffer_fastpath()
   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
 " ---------------------------------
index d38a46661314737f8d3933263c688bc13dbf4554..0ced1173e4b4a9bbdb2c6dfc09ed0a106ff4a1c1 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    37,
 /**/
     36,
 /**/