Untangle some fuzzy completion logic

Prior to this fix, when performing completions, we would prepend
the wildcard to the resulting files. When doing fuzzy completions,
we would take some wildcard segment, attempt to locate it in the
final completion, and then replace it with our fuzzy-matched directory.

With this fix, we pass along the "resolved so far" path, and prepend
that instead of doing "surgery" on the completion. This simplifies the
logic.

Fixes #3185
This commit is contained in:
ridiculousfish
2016-07-09 15:27:10 -07:00
parent a6cd12a7f1
commit 8b06d2ad66
2 changed files with 82 additions and 84 deletions

View File

@@ -1225,6 +1225,9 @@ static void test_expand() {
expand_test(L"/tmp/fish_expand_test/**z/xxx", 0, L"/tmp/fish_expand_test/baz/xxx", wnull,
L"Glob did the wrong thing 3");
expand_test(L"/tmp/fish_expand_test////baz/xxx", 0, L"/tmp/fish_expand_test////baz/xxx", wnull,
L"Glob did the wrong thing 3");
expand_test(L"/tmp/fish_expand_test/b**", 0, L"/tmp/fish_expand_test/b",
L"/tmp/fish_expand_test/b/x", L"/tmp/fish_expand_test/bar",
L"/tmp/fish_expand_test/bax", L"/tmp/fish_expand_test/bax/xxx",
@@ -1290,6 +1293,11 @@ static void test_expand() {
expand_test(L"b/xx", EXPAND_FOR_COMPLETIONS | EXPAND_FUZZY_MATCH, L"bax/xxx", L"baz/xxx", wnull,
L"Wrong fuzzy matching 5");
// multiple slashes with fuzzy matching - #3185
expand_test(L"l///n", EXPAND_FOR_COMPLETIONS | EXPAND_FUZZY_MATCH,
L"lol///nub/", wnull,
L"Wrong fuzzy matching 6");
if (chdir_set_pwd(saved_wd)) {
err(L"chdir failed");
}