mirror of
https://github.com/neovim/neovim.git
synced 2025-09-23 19:48:32 +00:00
vim-patch:9.1.1135: 'suffixesadd' doesn't work with multiple items (#32573)
Problem: 'suffixesadd' doesn't work with multiple items
(after 9.1.1122).
Solution: Don't concat multiple suffixes together.
(zeertzjq)
fixes: vim/vim#16694
closes: vim/vim#16699
bf595ae4ac
This commit is contained in:
@@ -856,6 +856,7 @@ char *vim_findfile(void *search_ctx_arg)
|
|||||||
|
|
||||||
// Try without extra suffix and then with suffixes
|
// Try without extra suffix and then with suffixes
|
||||||
// from 'suffixesadd'.
|
// from 'suffixesadd'.
|
||||||
|
len = file_path.size;
|
||||||
char *suf = search_ctx->ffsc_tagfile ? "" : curbuf->b_p_sua;
|
char *suf = search_ctx->ffsc_tagfile ? "" : curbuf->b_p_sua;
|
||||||
while (true) {
|
while (true) {
|
||||||
// if file exists and we didn't already find it
|
// if file exists and we didn't already find it
|
||||||
@@ -916,8 +917,8 @@ char *vim_findfile(void *search_ctx_arg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert(MAXPATHL >= file_path.size);
|
assert(MAXPATHL >= file_path.size);
|
||||||
file_path.size += copy_option_part(&suf, file_path.data + file_path.size,
|
file_path.size = len + copy_option_part(&suf, file_path.data + len,
|
||||||
MAXPATHL - file_path.size, ",");
|
MAXPATHL - len, ",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1515,20 +1516,20 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
// When the file doesn't exist, try adding parts of 'suffixesadd'.
|
// When the file doesn't exist, try adding parts of 'suffixesadd'.
|
||||||
|
size_t NameBufflen = l;
|
||||||
char *suffix = suffixes;
|
char *suffix = suffixes;
|
||||||
while (true) {
|
while (true) {
|
||||||
if ((os_path_exists(NameBuff)
|
if ((os_path_exists(NameBuff)
|
||||||
&& (find_what == FINDFILE_BOTH
|
&& (find_what == FINDFILE_BOTH
|
||||||
|| ((find_what == FINDFILE_DIR)
|
|| ((find_what == FINDFILE_DIR) == os_isdir(NameBuff))))) {
|
||||||
== os_isdir(NameBuff))))) {
|
file_name = xmemdupz(NameBuff, NameBufflen);
|
||||||
file_name = xmemdupz(NameBuff, l);
|
|
||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
if (*suffix == NUL) {
|
if (*suffix == NUL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert(MAXPATHL >= l);
|
assert(MAXPATHL >= l);
|
||||||
l += copy_option_part(&suffix, NameBuff + l, MAXPATHL - l, ",");
|
NameBufflen = l + copy_option_part(&suffix, NameBuff + l, MAXPATHL - l, ",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -222,6 +222,36 @@ func Test_finddir_error()
|
|||||||
call assert_fails('call finddir("x", repeat("x", 5000))', 'E854:')
|
call assert_fails('call finddir("x", repeat("x", 5000))', 'E854:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_findfile_with_suffixesadd()
|
||||||
|
let save_path = &path
|
||||||
|
let save_dir = getcwd()
|
||||||
|
set path=,,
|
||||||
|
call mkdir('Xfinddir1', 'pR')
|
||||||
|
cd Xfinddir1
|
||||||
|
|
||||||
|
call writefile([], 'foo.c', 'D')
|
||||||
|
call writefile([], 'bar.cpp', 'D')
|
||||||
|
call writefile([], 'baz.cc', 'D')
|
||||||
|
call writefile([], 'foo.o', 'D')
|
||||||
|
call writefile([], 'bar.o', 'D')
|
||||||
|
call writefile([], 'baz.o', 'D')
|
||||||
|
|
||||||
|
set suffixesadd=.c,.cpp
|
||||||
|
call assert_equal('foo.c', findfile('foo'))
|
||||||
|
call assert_equal('./foo.c', findfile('./foo'))
|
||||||
|
call assert_equal('bar.cpp', findfile('bar'))
|
||||||
|
call assert_equal('./bar.cpp', findfile('./bar'))
|
||||||
|
call assert_equal('', findfile('baz'))
|
||||||
|
call assert_equal('', findfile('./baz'))
|
||||||
|
set suffixesadd+=.cc
|
||||||
|
call assert_equal('baz.cc', findfile('baz'))
|
||||||
|
call assert_equal('./baz.cc', findfile('./baz'))
|
||||||
|
|
||||||
|
set suffixesadd&
|
||||||
|
call chdir(save_dir)
|
||||||
|
let &path = save_path
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for the :find, :sfind and :tabfind commands
|
" Test for the :find, :sfind and :tabfind commands
|
||||||
func Test_find_cmd()
|
func Test_find_cmd()
|
||||||
new
|
new
|
||||||
|
@@ -361,4 +361,36 @@ func Test_gf_switchbuf()
|
|||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_gf_with_suffixesadd()
|
||||||
|
let cwd = getcwd()
|
||||||
|
let dir = 'Xtestgf_sua_dir'
|
||||||
|
call mkdir(dir, 'R')
|
||||||
|
call chdir(dir)
|
||||||
|
|
||||||
|
call writefile([], 'foo.c', 'D')
|
||||||
|
call writefile([], 'bar.cpp', 'D')
|
||||||
|
call writefile([], 'baz.cc', 'D')
|
||||||
|
call writefile([], 'foo.o', 'D')
|
||||||
|
call writefile([], 'bar.o', 'D')
|
||||||
|
call writefile([], 'baz.o', 'D')
|
||||||
|
|
||||||
|
new
|
||||||
|
setlocal path=,, suffixesadd=.c,.cpp
|
||||||
|
call setline(1, ['./foo', './bar', './baz'])
|
||||||
|
exe "normal! gg\<C-W>f"
|
||||||
|
call assert_equal('foo.c', expand('%:t'))
|
||||||
|
close
|
||||||
|
exe "normal! 2gg\<C-W>f"
|
||||||
|
call assert_equal('bar.cpp', expand('%:t'))
|
||||||
|
close
|
||||||
|
call assert_fails('exe "normal! 3gg\<C-W>f"', 'E447:')
|
||||||
|
setlocal suffixesadd+=.cc
|
||||||
|
exe "normal! 3gg\<C-W>f"
|
||||||
|
call assert_equal('baz.cc', expand('%:t'))
|
||||||
|
close
|
||||||
|
|
||||||
|
%bwipe!
|
||||||
|
call chdir(cwd)
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user