mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #25236 from lsvmello/fix-gf
This commit is contained in:
commit
01374446af
@ -203,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|).
|
||||||
|
@ -3453,7 +3453,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
|
|
||||||
*'isfname'* *'isf'*
|
*'isfname'* *'isf'*
|
||||||
'isfname' 'isf' string (default for Windows:
|
'isfname' 'isf' string (default for Windows:
|
||||||
"@,48-57,/,\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,="
|
"@,48-57,/,\,.,-,_,+,,,#,$,%,{,},[,],@-@,!,~,="
|
||||||
otherwise: "@,48-57,/,.,-,_,+,,,#,$,%,~,=")
|
otherwise: "@,48-57,/,.,-,_,+,,,#,$,%,~,=")
|
||||||
global
|
global
|
||||||
The characters specified by this option are included in file names and
|
The characters specified by this option are included in file names and
|
||||||
|
@ -53,6 +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). Drive letters are handled
|
||||||
|
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
|
||||||
|
@ -4298,9 +4298,9 @@ return {
|
|||||||
defaults = {
|
defaults = {
|
||||||
condition = 'BACKSLASH_IN_FILENAME',
|
condition = 'BACKSLASH_IN_FILENAME',
|
||||||
if_false = '@,48-57,/,.,-,_,+,,,#,$,%,~,=',
|
if_false = '@,48-57,/,.,-,_,+,,,#,$,%,~,=',
|
||||||
if_true = '@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=',
|
if_true = '@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],@-@,!,~,=',
|
||||||
doc = [[for Windows:
|
doc = [[for Windows:
|
||||||
"@,48-57,/,\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,="
|
"@,48-57,/,\,.,-,_,+,,,#,$,%,{,},[,],@-@,!,~,="
|
||||||
otherwise: "@,48-57,/,.,-,_,+,,,#,$,%,~,="]],
|
otherwise: "@,48-57,/,.,-,_,+,,,#,$,%,~,="]],
|
||||||
},
|
},
|
||||||
deny_duplicates = true,
|
deny_duplicates = true,
|
||||||
|
@ -6943,11 +6943,13 @@ char *file_name_in_line(char *line, int col, int options, int count, char *rel_f
|
|||||||
bool is_url = false;
|
bool is_url = false;
|
||||||
|
|
||||||
// Search backward for first char of the file name.
|
// Search backward for first char of the file name.
|
||||||
// Go one char back to ":" before "//" even when ':' is not in 'isfname'.
|
// Go one char back to ":" before "//", or to the drive letter before ":\" (even if ":"
|
||||||
|
// is not in 'isfname').
|
||||||
while (ptr > line) {
|
while (ptr > line) {
|
||||||
if ((len = (size_t)(utf_head_off(line, ptr - 1))) > 0) {
|
if ((len = (size_t)(utf_head_off(line, ptr - 1))) > 0) {
|
||||||
ptr -= len + 1;
|
ptr -= len + 1;
|
||||||
} else if (vim_isfilec((uint8_t)ptr[-1])
|
} else if (vim_isfilec((uint8_t)ptr[-1])
|
||||||
|
|| (len >= 2 && path_has_drive_letter(ptr - 2))
|
||||||
|| ((options & FNAME_HYP) && path_is_url(ptr - 1))) {
|
|| ((options & FNAME_HYP) && path_is_url(ptr - 1))) {
|
||||||
ptr--;
|
ptr--;
|
||||||
} else {
|
} else {
|
||||||
@ -6957,14 +6959,13 @@ char *file_name_in_line(char *line, int col, int options, int count, char *rel_f
|
|||||||
|
|
||||||
// Search forward for the last char of the file name.
|
// Search forward for the last char of the file name.
|
||||||
// Also allow ":/" when ':' is not in 'isfname'.
|
// Also allow ":/" when ':' is not in 'isfname'.
|
||||||
len = 0;
|
len = path_has_drive_letter(ptr) ? 2 : 0;
|
||||||
while (vim_isfilec((uint8_t)ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ')
|
while (vim_isfilec((uint8_t)ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ')
|
||||||
|| ((options & FNAME_HYP) && path_is_url(ptr + len))
|
|| ((options & FNAME_HYP) && path_is_url(ptr + len))
|
||||||
|| (is_url && vim_strchr(":?&=", (uint8_t)ptr[len]) != NULL)) {
|
|| (is_url && vim_strchr(":?&=", (uint8_t)ptr[len]) != NULL)) {
|
||||||
// After type:// we also include :, ?, & and = as valid characters, so that
|
// After type:// we also include :, ?, & and = as valid characters, so that
|
||||||
// http://google.com:8080?q=this&that=ok works.
|
// http://google.com:8080?q=this&that=ok works.
|
||||||
if ((ptr[len] >= 'A' && ptr[len] <= 'Z')
|
if ((ptr[len] >= 'A' && ptr[len] <= 'Z') || (ptr[len] >= 'a' && ptr[len] <= 'z')) {
|
||||||
|| (ptr[len] >= 'a' && ptr[len] <= 'z')) {
|
|
||||||
if (in_type && path_is_url(ptr + len + 1)) {
|
if (in_type && path_is_url(ptr + len + 1)) {
|
||||||
is_url = true;
|
is_url = true;
|
||||||
}
|
}
|
||||||
|
@ -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()
|
||||||
@ -91,4 +91,42 @@ describe('file search', function()
|
|||||||
feed('gf')
|
feed('gf')
|
||||||
eq('filename_with_unicode_ααα', eval('expand("%:t")'))
|
eq('filename_with_unicode_ααα', eval('expand("%:t")'))
|
||||||
end)
|
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)
|
end)
|
||||||
|
@ -26,6 +26,9 @@ if exists('s:did_load')
|
|||||||
set sessionoptions+=options
|
set sessionoptions+=options
|
||||||
set viewoptions+=options
|
set viewoptions+=options
|
||||||
set switchbuf=
|
set switchbuf=
|
||||||
|
if has('win32')
|
||||||
|
set isfname+=:
|
||||||
|
endif
|
||||||
if g:testname !~ 'test_mapping.vim$'
|
if g:testname !~ 'test_mapping.vim$'
|
||||||
" Make "Q" switch to Ex mode.
|
" Make "Q" switch to Ex mode.
|
||||||
" This does not work for all tests.
|
" This does not work for all tests.
|
||||||
|
Loading…
Reference in New Issue
Block a user