Skip to content

Commit 8fea220

Browse files
committed
updated for version 7.3.1297
Problem: findfile() directory matching does not work when a star follows text. (Markus Braun) Solution: Make a wildcard work properly. (Christian Brabandt)
1 parent d834eb5 commit 8fea220

File tree

4 files changed

+75
-5
lines changed

4 files changed

+75
-5
lines changed

src/misc2.c

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4679,8 +4679,58 @@ vim_findfile_init(path, filename, stopdirs, level, free_visited, find_what,
46794679
}
46804680
STRCPY(ff_expand_buffer, search_ctx->ffsc_start_dir);
46814681
add_pathsep(ff_expand_buffer);
4682-
STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path);
4683-
add_pathsep(ff_expand_buffer);
4682+
{
4683+
char_u *buf = alloc(STRLEN(ff_expand_buffer)
4684+
+ STRLEN(search_ctx->ffsc_fix_path));
4685+
4686+
STRCPY(buf, ff_expand_buffer);
4687+
STRCAT(buf, search_ctx->ffsc_fix_path);
4688+
if (mch_isdir(buf))
4689+
{
4690+
STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path);
4691+
add_pathsep(ff_expand_buffer);
4692+
}
4693+
#ifdef FEAT_PATH_EXTRA
4694+
else
4695+
{
4696+
char_u *p = vim_strrchr(search_ctx->ffsc_fix_path, PATHSEP);
4697+
char_u *wc_path = NUL;
4698+
char_u *temp = NUL;
4699+
int len = 0;
4700+
4701+
if (p != NULL)
4702+
{
4703+
len = p - search_ctx->ffsc_fix_path;
4704+
STRNCAT(ff_expand_buffer, search_ctx->ffsc_fix_path, len);
4705+
add_pathsep(ff_expand_buffer);
4706+
}
4707+
else
4708+
len = STRLEN(search_ctx->ffsc_fix_path);
4709+
4710+
if (search_ctx->ffsc_wc_path != NULL)
4711+
{
4712+
wc_path = vim_strsave(search_ctx->ffsc_wc_path);
4713+
temp = alloc(STRLEN(search_ctx->ffsc_wc_path)
4714+
+ (STRLEN(search_ctx->ffsc_fix_path) - len));
4715+
}
4716+
4717+
if (temp == NULL || wc_path == NULL)
4718+
{
4719+
vim_free(buf);
4720+
vim_free(temp);
4721+
vim_free(wc_path);
4722+
goto error_return;
4723+
}
4724+
4725+
STRCPY(temp, search_ctx->ffsc_fix_path + len);
4726+
STRCAT(temp, search_ctx->ffsc_wc_path);
4727+
vim_free(search_ctx->ffsc_wc_path);
4728+
vim_free(wc_path);
4729+
search_ctx->ffsc_wc_path = temp;
4730+
}
4731+
#endif
4732+
vim_free(buf);
4733+
}
46844734

46854735
sptr = ff_create_stack_element(ff_expand_buffer,
46864736
#ifdef FEAT_PATH_EXTRA

src/testdir/test89.in

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
Some tests for setting 'number' and 'relativenumber'
2-
This is not all that useful now that the options are no longer reset when
3-
setting the other.
1+
- Some tests for setting 'number' and 'relativenumber'
2+
This is not all that useful now that the options are no longer reset when
3+
setting the other.
4+
- Some tests for findfile() function
45

56
STARTTEST
67
:so small.vim
@@ -49,6 +50,17 @@ STARTTEST
4950
:$put g
5051
:$put h
5152
:"
53+
:let cwd=getcwd()
54+
:cd ../..
55+
:$put =''
56+
:$put ='Testing findfile'
57+
:$put =''
58+
:$put =findfile('test19.in','src/test*')
59+
:exe "cd" cwd
60+
:cd ..
61+
:$put =findfile('test19.in','test*')
62+
:$put =findfile('test19.in','testdir')
63+
:exe "cd" cwd
5264
:/^results/,$w! test.out
5365
:q!
5466
ENDTEST

src/testdir/test89.ok

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ results:
2020
number
2121

2222
relativenumber
23+
24+
Testing findfile
25+
26+
src/testdir/test19.in
27+
testdir/test19.in
28+
testdir/test19.in

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,8 @@ static char *(features[]) =
728728

729729
static int included_patches[] =
730730
{ /* Add new patch number below this line */
731+
/**/
732+
1297,
731733
/**/
732734
1296,
733735
/**/

0 commit comments

Comments
 (0)