patch 9.1.0568: Cannot expand paths from 'cdpath' setting
Problem: Cannot expand paths from 'cdpath' setting
(Daniel Hahler)
Solution: Implement 'cdpath' completion, add the new 'dir_in_path'
completion type (LemonBoy)
fixes #374
closes: #15205
Signed-off-by: LemonBoy <thatlemon@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/filepath.c b/src/filepath.c
index 788d3bb..d514aaf 100644
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -4003,6 +4003,8 @@
int add_pat;
int retval = OK;
int did_expand_in_path = FALSE;
+ char_u *path_option = *curbuf->b_p_path == NUL ?
+ p_path : curbuf->b_p_path;
/*
* expand_env() is called to expand things like "~user". If this fails,
@@ -4092,7 +4094,7 @@
*/
if (mch_has_exp_wildcard(p) || (flags & EW_ICASE))
{
- if ((flags & EW_PATH)
+ if ((flags & (EW_PATH | EW_CDPATH))
&& !mch_isFullName(p)
&& !(p[0] == '.'
&& (vim_ispathsep(p[1])
@@ -4126,8 +4128,8 @@
vim_free(t);
}
- if (did_expand_in_path && ga.ga_len > 0 && (flags & EW_PATH))
- uniquefy_paths(&ga, p);
+ if (did_expand_in_path && ga.ga_len > 0 && (flags & (EW_PATH | EW_CDPATH)))
+ uniquefy_paths(&ga, p, path_option);
if (p != pat[i])
vim_free(p);
}