mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
Fix false positive cd higlighting when token ends in slash
We wrongly highlight this as prefix when actually the trailing slash should invalidate it. Turns out path normalization drops the slash, so let's sidestep that. Fixes #9394
This commit is contained in:
parent
4159b2a33b
commit
6072ea1900
2 changed files with 2 additions and 1 deletions
|
@ -2874,6 +2874,7 @@ static void test_is_potential_path() {
|
|||
do_test(is_potential_path(L"alpha/", true, wds, ctx, PATH_REQUIRE_DIR));
|
||||
do_test(is_potential_path(L"aard", true, wds, ctx, 0));
|
||||
do_test(!is_potential_path(L"aard", false, wds, ctx, 0));
|
||||
do_test(!is_potential_path(L"alp/", true, wds, ctx, PATH_REQUIRE_DIR | PATH_FOR_CD));
|
||||
|
||||
do_test(!is_potential_path(L"balpha/", true, wds, ctx, PATH_REQUIRE_DIR));
|
||||
do_test(!is_potential_path(L"aard", true, wds, ctx, PATH_REQUIRE_DIR));
|
||||
|
|
|
@ -236,6 +236,7 @@ bool is_potential_path(const wcstring &potential_path_fragment, bool at_cursor,
|
|||
for (const wcstring &wd : directories) {
|
||||
if (ctx.check_cancel()) return false;
|
||||
wcstring abs_path = path_apply_working_directory(clean_potential_path_fragment, wd);
|
||||
bool must_be_full_dir = abs_path.at(abs_path.size() - 1) == L'/';
|
||||
if (flags & PATH_FOR_CD) {
|
||||
abs_path = normalize_path(abs_path);
|
||||
}
|
||||
|
@ -250,7 +251,6 @@ bool is_potential_path(const wcstring &potential_path_fragment, bool at_cursor,
|
|||
// 1. If the argument ends with a slash, it must be a valid directory, no prefix.
|
||||
// 2. If the cursor is not at the argument, it means the user is definitely not typing it,
|
||||
// so we can skip the prefix-match.
|
||||
bool must_be_full_dir = abs_path.at(abs_path.size() - 1) == L'/';
|
||||
if (must_be_full_dir || !at_cursor) {
|
||||
struct stat buf;
|
||||
if (0 == wstat(abs_path, &buf) && (!at_cursor || S_ISDIR(buf.st_mode))) {
|
||||
|
|
Loading…
Reference in a new issue