diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2023-10-06 12:59:39 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2023-10-06 14:09:21 +0200 |
commit | 133e2990efa44cadf1410a452a08843dbd8ca86e (patch) | |
tree | e52036a0938de7576da9bab3195c2d3bfda4d54c | |
parent | 56dc8b9212ef3a1eebe8e32266d4b6735b3c557b (diff) | |
download | rneovim-133e2990efa44cadf1410a452a08843dbd8ca86e.tar.gz rneovim-133e2990efa44cadf1410a452a08843dbd8ca86e.tar.bz2 rneovim-133e2990efa44cadf1410a452a08843dbd8ca86e.zip |
refactor: cleanup
-rw-r--r-- | runtime/doc/news.txt | 5 | ||||
-rw-r--r-- | runtime/doc/vim_diff.txt | 4 | ||||
-rw-r--r-- | test/functional/core/path_spec.lua | 106 |
3 files changed, 38 insertions, 77 deletions
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 2bf912dbfd..b0f3b76587 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -15,9 +15,6 @@ BREAKING CHANGES *news-breaking* The following changes may require adaptations in user config or plugins. -• Windows file path drive letters are now detected even if ":" is not in - 'isfname'. The default 'isfname' no longer includes ":". - • |vim.tbl_islist()| now checks whether a table is actually list-like (i.e., has integer keys without gaps and starting from 1). For the previous behavior (only check for integer keys, allow gaps or not starting with 1), @@ -206,6 +203,8 @@ The following changes to existing APIs or features add new behavior. option, which allows for rendering e.g., diagnostic severities differently. • Defaults: + • On Windows 'isfname' does not include ":". Drive letters are handled + correctly without it. (Use |gF| for filepaths suffixed with ":line:col"). • 'comments' includes "fb:•". • 'shortmess' includes the "C" flag. • Automatic linting of treesitter query files (see |ft-query-plugin|). diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 974aa051cf..4161d3b21e 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -53,8 +53,8 @@ Defaults *nvim-defaults* - 'hlsearch' is enabled - 'include' defaults to "". The C ftplugin sets it to "^\\s*#\\s*include" - 'incsearch' is enabled -- 'isfname' does not include ":" on Windows. Include ":" in 'isfname' to treat - it as part of a filename anywhere in the name (not only the drive letter). +- 'isfname' does not include ":" (on Windows). Drive letters are handled + correctly without it. (Use |gF| for filepaths suffixed with ":line:col"). - 'joinspaces' is disabled - 'langnoremap' is enabled - 'langremap' is disabled diff --git a/test/functional/core/path_spec.lua b/test/functional/core/path_spec.lua index 1c6faf8d60..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() @@ -93,78 +93,40 @@ describe('file search', function() 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') + 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 - 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>")')) + 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) |