mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00:00
Implicitly use $PWD in $CDPATH in completions and highlighting
We already do for the actual cd-ing itself. Missed in #4484. Fixes #8161.
This commit is contained in:
parent
c35ffc58fc
commit
859edc9c2c
3 changed files with 10 additions and 3 deletions
|
@ -1079,9 +1079,9 @@ expand_result_t expander_t::stage_wildcards(wcstring path_to_expand, completion_
|
|||
if (auto paths_var = ctx.vars.get(for_cd ? L"CDPATH" : L"PATH")) {
|
||||
paths = paths_var->as_list();
|
||||
}
|
||||
if (paths.empty()) {
|
||||
paths.emplace_back(for_cd ? L"." : L"");
|
||||
}
|
||||
|
||||
// The current directory is always valid.
|
||||
paths.emplace_back(for_cd ? L"." : L"");
|
||||
for (const wcstring &next_path : paths) {
|
||||
effective_working_dirs.push_back(
|
||||
path_apply_working_directory(next_path, working_dir));
|
||||
|
|
|
@ -322,6 +322,8 @@ static bool is_potential_cd_path(const wcstring &path, const wcstring &working_d
|
|||
auto cdpath = ctx.vars.get(L"CDPATH");
|
||||
wcstring_list_t pathsv =
|
||||
cdpath.missing_or_empty() ? wcstring_list_t{L"."} : cdpath->as_list();
|
||||
// The current $PWD is always valid.
|
||||
pathsv.push_back(L".");
|
||||
|
||||
for (auto next_path : pathsv) {
|
||||
if (next_path.empty()) next_path = L".";
|
||||
|
|
|
@ -163,6 +163,11 @@ mkdir -p cdpath-dir/nonexistent
|
|||
mkdir -p cdpath-dir/file
|
||||
set CDPATH $PWD/cdpath-dir $old_cdpath
|
||||
|
||||
# See that the completions also check the current directory
|
||||
complete -C'cd ' | string match -q cdpath-dir/
|
||||
and echo cdpath-dir is in
|
||||
# CHECK: cdpath-dir is in
|
||||
|
||||
# A different directory with the same name that is first in $CDPATH works.
|
||||
cd bad-perms
|
||||
cd $old_path
|
||||
|
|
Loading…
Reference in a new issue