mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
fix(completion): filter results with complete+=f (#26029)
This commit is contained in:
@@ -3325,24 +3325,10 @@ static void get_next_bufname_token(void)
|
|||||||
{
|
{
|
||||||
FOR_ALL_BUFFERS(b) {
|
FOR_ALL_BUFFERS(b) {
|
||||||
if (b->b_p_bl && b->b_sfname != NULL) {
|
if (b->b_p_bl && b->b_sfname != NULL) {
|
||||||
char *start = get_past_head(b->b_sfname);
|
char *tail = path_tail(b->b_sfname);
|
||||||
char *current = start;
|
if (strncmp(tail, compl_orig_text, strlen(compl_orig_text)) == 0) {
|
||||||
char *p = (char *)path_next_component(start);
|
ins_compl_add(tail, (int)strlen(tail), NULL, NULL, false, NULL, 0,
|
||||||
while (true) {
|
|
||||||
int len = (int)(p - current) - (*p == NUL ? 0 : 1);
|
|
||||||
// treat . as a separator, unless it is the first char in a filename
|
|
||||||
char *dot = strchr(current, '.');
|
|
||||||
if (dot && *p == NUL && *current != '.') {
|
|
||||||
len = (int)(dot - current);
|
|
||||||
p = dot + 1;
|
|
||||||
}
|
|
||||||
ins_compl_add(current, len, NULL, NULL, false, NULL, 0,
|
|
||||||
p_ic ? CP_ICASE : 0, false);
|
p_ic ? CP_ICASE : 0, false);
|
||||||
if (*p == NUL) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
current = p;
|
|
||||||
p = (char *)path_next_component(p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1231,25 +1231,30 @@ describe('completion', function()
|
|||||||
|
|
||||||
it('complete with f flag #25598', function()
|
it('complete with f flag #25598', function()
|
||||||
screen:try_resize(20, 9)
|
screen:try_resize(20, 9)
|
||||||
local bufname = 'foo/bar.txt'
|
command('set complete+=f | edit foo | edit bar |edit foa |edit .hidden')
|
||||||
local hidden = 'fooA/.hidden'
|
|
||||||
if helpers.is_os('win') then
|
|
||||||
bufname = 'C:\\foo\\bar.txt'
|
|
||||||
hidden = 'C:\\fooA\\.hidden'
|
|
||||||
end
|
|
||||||
command('set complete+=f | edit '..bufname..' | edit '..hidden..' | enew')
|
|
||||||
feed('i<C-n>')
|
feed('i<C-n>')
|
||||||
|
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
foo^ |
|
foo^ |
|
||||||
{2:foo }{0: }|
|
{2:foo }{0: }|
|
||||||
{1:bar }{0: }|
|
{1:bar }{0: }|
|
||||||
{1:txt }{0: }|
|
{1:foa }{0: }|
|
||||||
{1:fooA }{0: }|
|
|
||||||
{1:.hidden }{0: }|
|
{1:.hidden }{0: }|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{3:-- }{4:match 1 of 5} |
|
{0:~ }|
|
||||||
|
{3:-- }{4:match 1 of 4} |
|
||||||
|
]]}
|
||||||
|
feed('<Esc>ccf<C-n>')
|
||||||
|
screen:expect{grid=[[
|
||||||
|
foo^ |
|
||||||
|
{2:foo }{0: }|
|
||||||
|
{1:foa }{0: }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{3:-- }{4:match 1 of 2} |
|
||||||
]]}
|
]]}
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user