aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core
diff options
context:
space:
mode:
authorLeonardo Mello <lsvmello@gmail.com>2023-09-18 16:50:47 -0300
committerJustin M. Keyes <justinkz@gmail.com>2023-10-06 12:59:58 +0200
commit1dd700a8d9275439fbc71ac5adeb59914bdbd5cf (patch)
tree943ad468a200645b9d7520363dbf76fccb5767f7 /test/functional/core
parent4e4ad4312e6b3755a2114ab81c62033e6bc616fe (diff)
downloadrneovim-1dd700a8d9275439fbc71ac5adeb59914bdbd5cf.tar.gz
rneovim-1dd700a8d9275439fbc71ac5adeb59914bdbd5cf.tar.bz2
rneovim-1dd700a8d9275439fbc71ac5adeb59914bdbd5cf.zip
fix: gf fails on "foo/bar.txt:1:2" on Windows
Problem: On Windows, "gf" fails on a filepath that has a line:column suffix. Example: E447: Can't find file "src/app/core/services/identity/identity.service.ts:64:23" Solution: - Remove ":" from 'isfname' on Windows. Colon is not a valid filename character (except for the drive-letter). - Handle drive letters specially in file_name_in_line(). Fixes #25160
Diffstat (limited to 'test/functional/core')
-rw-r--r--test/functional/core/path_spec.lua76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/functional/core/path_spec.lua b/test/functional/core/path_spec.lua
index 6c677d76d1..1c6faf8d60 100644
--- a/test/functional/core/path_spec.lua
+++ b/test/functional/core/path_spec.lua
@@ -91,4 +91,80 @@ 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 os_win = is_os('win')
+
+ insert([[c:/d:/foo/bar.txt]])
+ eq([[c:/d:/foo/bar.txt]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[//share/c:/foo/bar/]])
+ eq([[//share/c:/foo/bar/]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[file://c:/foo/bar]])
+ eq([[file://c:/foo/bar]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[https://c:/foo/bar]])
+ eq([[https://c:/foo/bar]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[\foo\bar]])
+ eq(os_win and [[\foo\bar]] or [[bar]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[/foo/bar]])
+ eq([[/foo/bar]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[c:\foo\bar]])
+ eq(os_win and [[c:\foo\bar]] or [[bar]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[c:/foo/bar]])
+ eq([[c:/foo/bar]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[c:foo\bar]])
+ eq(os_win and [[foo\bar]] or [[bar]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[c:foo/bar]])
+ eq([[foo/bar]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[c:foo]])
+ eq([[foo]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ -- Examples from: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#example-ways-to-refer-to-the-same-file
+ insert([[c:\temp\test-file.txt]])
+ eq(os_win and [[c:\temp\test-file.txt]] or [[test-file.txt]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[\\127.0.0.1\c$\temp\test-file.txt]])
+ eq(os_win and [[\\127.0.0.1\c$\temp\test-file.txt]] or [[test-file.txt]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[\\LOCALHOST\c$\temp\test-file.txt]])
+ eq(os_win and [[\\LOCALHOST\c$\temp\test-file.txt]] or [[test-file.txt]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[\\.\c:\temp\test-file.txt]]) -- not supported yet
+ eq(os_win and [[\\.\c]] or [[test-file.txt]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[\\?\c:\temp\test-file.txt]]) -- not supported yet
+ eq(os_win and [[\c]] or [[test-file.txt]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[\\.\UNC\LOCALHOST\c$\temp\test-file.txt]])
+ eq(os_win and [[\\.\UNC\LOCALHOST\c$\temp\test-file.txt]] or [[test-file.txt]], eval('expand("<cfile>")'))
+ command('%delete')
+
+ insert([[\\127.0.0.1\c$\temp\test-file.txt]])
+ eq(os_win and [[\\127.0.0.1\c$\temp\test-file.txt]] or [[test-file.txt]], eval('expand("<cfile>")'))
+ end)
end)