fix(tui): avoid cwd-path matches in @ autocomplete

Only use fd --full-path for path queries so plain fuzzy @ autocomplete results no longer depend on whether the cwd path contains the query text.

closes #2778
This commit is contained in:
Mario Zechner
2026-04-20 22:44:34 +02:00
parent 7b1599058b
commit 968430f63e
3 changed files with 38 additions and 1 deletions

View File

@@ -4,6 +4,7 @@
### Fixed
- Fixed `@` autocomplete fuzzy search to stop matching against the full base path for plain queries, so worktree or cwd paths containing the query text no longer crowd out real results such as `@plan` suggestions ([#2778](https://github.com/badlogic/pi-mono/issues/2778))
- Fixed xterm `modifyOtherKeys` printable input so shifted uppercase letters insert correctly in the editor and shifted letter bindings parse and match consistently ([#3436](https://github.com/badlogic/pi-mono/issues/3436))
## [0.67.68] - 2026-04-17

View File

@@ -137,7 +137,6 @@ async function walkDirectoryWithFd(
"f",
"--type",
"d",
"--full-path",
"--hidden",
"--exclude",
".git",
@@ -147,6 +146,10 @@ async function walkDirectoryWithFd(
".git/**",
];
if (toDisplayPath(query).includes("/")) {
args.push("--full-path");
}
if (query) {
args.push(buildFdPathQuery(query));
}

View File

@@ -300,6 +300,39 @@ describe("CombinedAutocompleteProvider", () => {
assert.ok(!values.some((value) => value === "@.git" || value.startsWith("@.git/")));
});
test("returns the same @ suggestions when the cwd path contains the query", async () => {
const normalBaseDir = join(rootDir, "cwd-normal");
const queryInPathBaseDir = join(rootDir, "cwd-plan-repro");
mkdirSync(normalBaseDir, { recursive: true });
mkdirSync(queryInPathBaseDir, { recursive: true });
const structure = {
dirs: ["packages/coding-agent/examples/extensions/plan-mode"],
files: {
"packages/coding-agent/examples/extensions/plan-mode/README.md": "readme",
"packages/pods/docs/plan.md": "plan",
},
};
setupFolder(normalBaseDir, structure);
setupFolder(queryInPathBaseDir, structure);
const query = "@plan";
const normalProvider = new CombinedAutocompleteProvider([], normalBaseDir, requireFdPath());
const queryInPathProvider = new CombinedAutocompleteProvider([], queryInPathBaseDir, requireFdPath());
const normalResult = await getSuggestions(normalProvider, [query], 0, query.length);
const queryInPathResult = await getSuggestions(queryInPathProvider, [query], 0, query.length);
const normalize = (result: Awaited<ReturnType<typeof getSuggestions>>) =>
(result?.items ?? []).map((item) => `${item.label} :: ${item.description ?? ""}`).sort();
assert.deepStrictEqual(normalize(queryInPathResult), normalize(normalResult));
assert.ok(
normalize(normalResult).includes("plan-mode/ :: packages/coding-agent/examples/extensions/plan-mode"),
);
assert.ok(normalize(normalResult).includes("plan.md :: packages/pods/docs/plan.md"));
});
test("continues autocomplete inside quoted @ paths", async () => {
setupFolder(baseDir, {
files: {