refactor: cleanup

This commit is contained in:
Justin M. Keyes
2023-10-06 12:59:39 +02:00
parent 56dc8b9212
commit 133e2990ef
3 changed files with 38 additions and 77 deletions

View File

@@ -15,9 +15,6 @@ BREAKING CHANGES *news-breaking*
The following changes may require adaptations in user config or plugins. 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., • |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 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), 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. option, which allows for rendering e.g., diagnostic severities differently.
• Defaults: • 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:•". • 'comments' includes "fb:•".
• 'shortmess' includes the "C" flag. • 'shortmess' includes the "C" flag.
• Automatic linting of treesitter query files (see |ft-query-plugin|). • Automatic linting of treesitter query files (see |ft-query-plugin|).

View File

@@ -53,8 +53,8 @@ Defaults *nvim-defaults*
- 'hlsearch' is enabled - 'hlsearch' is enabled
- 'include' defaults to "". The C ftplugin sets it to "^\\s*#\\s*include" - 'include' defaults to "". The C ftplugin sets it to "^\\s*#\\s*include"
- 'incsearch' is enabled - 'incsearch' is enabled
- 'isfname' does not include ":" on Windows. Include ":" in 'isfname' to treat - 'isfname' does not include ":" (on Windows). Drive letters are handled
it as part of a filename anywhere in the name (not only the drive letter). correctly without it. (Use |gF| for filepaths suffixed with ":line:col").
- 'joinspaces' is disabled - 'joinspaces' is disabled
- 'langnoremap' is enabled - 'langnoremap' is enabled
- 'langremap' is disabled - 'langremap' is disabled

View File

@@ -81,7 +81,7 @@ describe('expand wildcard', function()
end) end)
end) end)
describe('file search', function() describe('file search (gf, <cfile>)', function()
before_each(clear) before_each(clear)
it('find multibyte file name in line #20517', function() it('find multibyte file name in line #20517', function()
@@ -93,78 +93,40 @@ describe('file search', function()
end) end)
it('matches Windows drive-letter filepaths (without ":" in &isfname)', function() it('matches Windows drive-letter filepaths (without ":" in &isfname)', function()
local os_win = is_os('win') local iswin = is_os('win')
local function test_cfile(input, expected, expected_win)
insert([[c:/d:/foo/bar.txt]]) expected = (iswin and expected_win or expected) or input
eq([[c:/d:/foo/bar.txt]], eval('expand("<cfile>")')) command('%delete')
command('%delete') insert(input)
command('norm! 0')
insert([[//share/c:/foo/bar/]]) eq(expected, eval('expand("<cfile>")'))
eq([[//share/c:/foo/bar/]], eval('expand("<cfile>")')) end
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')
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 -- 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]]) test_cfile([[c:\temp\test-file.txt]], [[c:]], [[c:\temp\test-file.txt]])
eq(os_win and [[c:\temp\test-file.txt]] or [[test-file.txt]], eval('expand("<cfile>")')) test_cfile([[\\127.0.0.1\c$\temp\test-file.txt]], [[127.0.0.1]], [[\\127.0.0.1\c$\temp\test-file.txt]])
command('%delete') test_cfile([[\\LOCALHOST\c$\temp\test-file.txt]], [[LOCALHOST]], [[\\LOCALHOST\c$\temp\test-file.txt]])
-- not supported yet
insert([[\\127.0.0.1\c$\temp\test-file.txt]]) test_cfile([[\\.\c:\temp\test-file.txt]], [[.]], [[\\.\c]])
eq(os_win and [[\\127.0.0.1\c$\temp\test-file.txt]] or [[test-file.txt]], eval('expand("<cfile>")')) -- not supported yet
command('%delete') test_cfile([[\\?\c:\temp\test-file.txt]], [[c:]], [[\\]])
test_cfile([[\\.\UNC\LOCALHOST\c$\temp\test-file.txt]], [[.]], [[\\.\UNC\LOCALHOST\c$\temp\test-file.txt]])
insert([[\\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]])
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)
end) end)