Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/pi-fff/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +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") {
const fuzzy = picker.grep(pattern, {
// 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),
Expand Down
Loading