aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-10-06 05:39:36 -0700
committerGitHub <noreply@github.com>2023-10-06 05:39:36 -0700
commit01374446af9663dde5c60a7067775418c2cbf135 (patch)
treee52036a0938de7576da9bab3195c2d3bfda4d54c /test
parent4e4ad4312e6b3755a2114ab81c62033e6bc616fe (diff)
parent133e2990efa44cadf1410a452a08843dbd8ca86e (diff)
downloadrneovim-01374446af9663dde5c60a7067775418c2cbf135.tar.gz
rneovim-01374446af9663dde5c60a7067775418c2cbf135.tar.bz2
rneovim-01374446af9663dde5c60a7067775418c2cbf135.zip
Merge #25236 from lsvmello/fix-gf
Diffstat (limited to 'test')
-rw-r--r--test/functional/core/path_spec.lua40
-rw-r--r--test/old/testdir/setup.vim3
2 files changed, 42 insertions, 1 deletions
diff --git a/test/functional/core/path_spec.lua b/test/functional/core/path_spec.lua
index 6c677d76d1..06fa13dca5 100644
--- a/test/functional/core/path_spec.lua
+++ b/test/functional/core/path_spec.lua
@@ -81,7 +81,7 @@ describe('expand wildcard', function()
end)
end)
-describe('file search', function()
+describe('file search (gf, <cfile>)', function()
before_each(clear)
it('find multibyte file name in line #20517', function()
@@ -91,4 +91,42 @@ describe('file search', function()
feed('gf')
eq('filename_with_unicode_ααα', eval('expand("%:t")'))
end)
+
+ it('matches Windows drive-letter filepaths (without ":" in &isfname)', function()
+ local iswin = is_os('win')
+ local function test_cfile(input, expected, expected_win)
+ expected = (iswin and expected_win or expected) or input
+ command('%delete')
+ insert(input)
+ command('norm! 0')
+ eq(expected, eval('expand("<cfile>")'))
+ end
+
+ test_cfile([[c:/d:/foo/bar.txt]]) -- TODO(justinmk): should return "d:/foo/bar.txt" ?
+ test_cfile([[//share/c:/foo/bar/]])
+ test_cfile([[file://c:/foo/bar]])
+ test_cfile([[file://c:/foo/bar:42]])
+ test_cfile([[file://c:/foo/bar:42:666]])
+ test_cfile([[https://c:/foo/bar]])
+ test_cfile([[\foo\bar]], [[foo]], [[\foo\bar]])
+ test_cfile([[/foo/bar]], [[/foo/bar]])
+ test_cfile([[c:\foo\bar]], [[c:]], [[c:\foo\bar]])
+ test_cfile([[c:\foo\bar:42:666]], [[c:]], [[c:\foo\bar]])
+ test_cfile([[c:/foo/bar]])
+ test_cfile([[c:/foo/bar:42]], [[c:/foo/bar]])
+ test_cfile([[c:/foo/bar:42:666]], [[c:/foo/bar]])
+ test_cfile([[c:foo\bar]], [[c]])
+ test_cfile([[c:foo/bar]], [[c]])
+ test_cfile([[c:foo]], [[c]])
+ -- Examples from: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#example-ways-to-refer-to-the-same-file
+ test_cfile([[c:\temp\test-file.txt]], [[c:]], [[c:\temp\test-file.txt]])
+ test_cfile([[\\127.0.0.1\c$\temp\test-file.txt]], [[127.0.0.1]], [[\\127.0.0.1\c$\temp\test-file.txt]])
+ test_cfile([[\\LOCALHOST\c$\temp\test-file.txt]], [[LOCALHOST]], [[\\LOCALHOST\c$\temp\test-file.txt]])
+ -- not supported yet
+ test_cfile([[\\.\c:\temp\test-file.txt]], [[.]], [[\\.\c]])
+ -- not supported yet
+ test_cfile([[\\?\c:\temp\test-file.txt]], [[c:]], [[\\]])
+ test_cfile([[\\.\UNC\LOCALHOST\c$\temp\test-file.txt]], [[.]], [[\\.\UNC\LOCALHOST\c$\temp\test-file.txt]])
+ test_cfile([[\\127.0.0.1\c$\temp\test-file.txt]], [[127.0.0.1]], [[\\127.0.0.1\c$\temp\test-file.txt]])
+ end)
end)
diff --git a/test/old/testdir/setup.vim b/test/old/testdir/setup.vim
index 096ddba40b..b0c2a15a3f 100644
--- a/test/old/testdir/setup.vim
+++ b/test/old/testdir/setup.vim
@@ -26,6 +26,9 @@ if exists('s:did_load')
set sessionoptions+=options
set viewoptions+=options
set switchbuf=
+ if has('win32')
+ set isfname+=:
+ endif
if g:testname !~ 'test_mapping.vim$'
" Make "Q" switch to Ex mode.
" This does not work for all tests.