From 645ef62d3f028d5222c24c189f6a2be6616551cf Mon Sep 17 00:00:00 2001 From: gustav-fff <286169375+gustav-fff@users.noreply.github.com> Date: Tue, 21 Jul 2026 10:40:02 -0700 Subject: [PATCH 1/2] fix(pi-fff): preserve path and exclude constraints in fuzzy grep fallback (#697) The automatic fuzzy fallback in the pi-fff `grep` tool passed the raw `pattern` to `picker.grep`, discarding the constrained `query` built via `buildQuery`. As a result, the fallback ignored the caller's `path` and `exclude` constraints and could return matches from explicitly excluded directories or files outside the requested path. Pass the constrained `query` to the fallback instead, so it only broadens matching (fuzzy vs. plain) without broadening scope. Closes #697 --- packages/pi-fff/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/pi-fff/src/index.ts b/packages/pi-fff/src/index.ts index 649aaca29..676e7fb43 100644 --- a/packages/pi-fff/src/index.ts +++ b/packages/pi-fff/src/index.ts @@ -724,7 +724,10 @@ export default function fffExtension(pi: ExtensionAPI) { // automatic fuzzy fallback allows to broad the queries and find different cases if (result.items.length === 0 && !params.cursor && mode !== "regex") { - const fuzzy = picker.grep(pattern, { + // Preserve the original path/exclude constraints — broadening only the + // pattern-match, not the scope. Otherwise the fallback can leak matches + // from excluded directories or files outside the requested path. + const fuzzy = picker.grep(query, { mode: "fuzzy", smartCase, maxMatchesPerFile: Math.min(effectiveLimit, 50), From d500af2b8f02ebad57d801b17ebcb7f0ef14c57f Mon Sep 17 00:00:00 2001 From: gustav-fff <286169375+gustav-fff@users.noreply.github.com> Date: Wed, 22 Jul 2026 14:49:01 -0700 Subject: [PATCH 2/2] fix(pi-fff): drop path constraint in fuzzy fallback only for file paths When the caller pinned a specific file (path has an extension), the fuzzy fallback broadens across the whole picker so a mistyped filename can still surface matches. For directory constraints (or no path), keep the constrained query so the fallback does not leak matches from excluded / out-of-scope directories. --- packages/pi-fff/src/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/pi-fff/src/index.ts b/packages/pi-fff/src/index.ts index 676e7fb43..3f0979eeb 100644 --- a/packages/pi-fff/src/index.ts +++ b/packages/pi-fff/src/index.ts @@ -724,10 +724,15 @@ export default function fffExtension(pi: ExtensionAPI) { // automatic fuzzy fallback allows to broad the queries and find different cases if (result.items.length === 0 && !params.cursor && mode !== "regex") { - // Preserve the original path/exclude constraints — broadening only the - // pattern-match, not the scope. Otherwise the fallback can leak matches - // from excluded directories or files outside the requested path. - const fuzzy = picker.grep(query, { + // When the caller pinned a specific file (path has an extension), the + // fuzzy fallback broadens across the whole picker — the file may just + // be misnamed. For directory constraints (or no path), we keep the + // constrained query so the fallback does not leak matches from + // excluded / out-of-scope directories. + const lastSeg = params.path?.split(/[\\/]/).pop() ?? ""; + const pathTargetsFile = /\.[a-zA-Z][a-zA-Z0-9]{0,9}$/.test(lastSeg); + const fuzzyQuery = pathTargetsFile ? pattern : query; + const fuzzy = picker.grep(fuzzyQuery, { mode: "fuzzy", smartCase, maxMatchesPerFile: Math.min(effectiveLimit, 50),