mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 08:18:17 +00:00
vim-patch:8.0.1464: add slash when completing directory #8684
Problem: Completing directory after :find does not add slash.
Solution: Adjust the flags for globpath(). (Genki Sky)
8a37b03289
This commit is contained in:

committed by
Justin M. Keyes

parent
d241f278d3
commit
2574f299e5
@@ -1051,30 +1051,35 @@ const char *gettail_dir(const char *const fname)
|
|||||||
* result in "gap".
|
* result in "gap".
|
||||||
* Returns the total number of matches.
|
* Returns the total number of matches.
|
||||||
*/
|
*/
|
||||||
static int
|
static int expand_in_path(
|
||||||
expand_in_path (
|
garray_T *const gap,
|
||||||
garray_T *gap,
|
char_u *const pattern,
|
||||||
char_u *pattern,
|
const int flags // EW_* flags
|
||||||
int flags /* EW_* flags */
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
char_u *curdir;
|
|
||||||
garray_T path_ga;
|
garray_T path_ga;
|
||||||
char_u *paths = NULL;
|
|
||||||
|
|
||||||
curdir = xmalloc(MAXPATHL);
|
char_u *const curdir = xmalloc(MAXPATHL);
|
||||||
os_dirname(curdir, MAXPATHL);
|
os_dirname(curdir, MAXPATHL);
|
||||||
|
|
||||||
ga_init(&path_ga, (int)sizeof(char_u *), 1);
|
ga_init(&path_ga, (int)sizeof(char_u *), 1);
|
||||||
expand_path_option(curdir, &path_ga);
|
expand_path_option(curdir, &path_ga);
|
||||||
xfree(curdir);
|
xfree(curdir);
|
||||||
if (GA_EMPTY(&path_ga))
|
if (GA_EMPTY(&path_ga)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
paths = ga_concat_strings(&path_ga);
|
char_u *const paths = ga_concat_strings(&path_ga);
|
||||||
ga_clear_strings(&path_ga);
|
ga_clear_strings(&path_ga);
|
||||||
|
|
||||||
globpath(paths, pattern, gap, (flags & EW_ICASE) ? WILD_ICASE : 0);
|
int glob_flags = 0;
|
||||||
|
if (flags & EW_ICASE) {
|
||||||
|
glob_flags |= WILD_ICASE;
|
||||||
|
}
|
||||||
|
if (flags & EW_ADDSLASH) {
|
||||||
|
glob_flags |= WILD_ADD_SLASH;
|
||||||
|
}
|
||||||
|
globpath(paths, pattern, gap, glob_flags);
|
||||||
xfree(paths);
|
xfree(paths);
|
||||||
|
|
||||||
return gap->ga_len;
|
return gap->ga_len;
|
||||||
|
@@ -88,6 +88,12 @@ func Test_find_complete()
|
|||||||
call feedkeys(":find f\t\n", "xt")
|
call feedkeys(":find f\t\n", "xt")
|
||||||
call assert_equal('Holy Grail', getline(1))
|
call assert_equal('Holy Grail', getline(1))
|
||||||
|
|
||||||
|
" Test that find completion on directory appends a slash
|
||||||
|
call feedkeys(":find in/pa\tfile.txt\n", "xt")
|
||||||
|
call assert_equal('E.T.', getline(1))
|
||||||
|
call feedkeys(":find ./i\tstuff.txt\n", "xt")
|
||||||
|
call assert_equal('Another Holy Grail', getline(1))
|
||||||
|
|
||||||
" Test shortening of
|
" Test shortening of
|
||||||
"
|
"
|
||||||
" foo/x/bar/voyager.txt
|
" foo/x/bar/voyager.txt
|
||||||
|
Reference in New Issue
Block a user