From 1fbd87210bc7c7a43a7f9f7aa34c6d5f7d860ea1 Mon Sep 17 00:00:00 2001 From: Shoubhit Dash Date: Fri, 27 Mar 2026 15:19:03 +0530 Subject: [PATCH] core: keep package file search results visible --- packages/opencode/src/file/index.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/file/index.ts b/packages/opencode/src/file/index.ts index 77bb3648e3..793b50826d 100644 --- a/packages/opencode/src/file/index.ts +++ b/packages/opencode/src/file/index.ts @@ -652,7 +652,9 @@ export namespace File { const query = input.query.trim() const limit = input.limit ?? 100 const kind = input.type ?? (input.dirs === false ? "file" : "all") - const fast = /[./\\]/.test(query) + const slash = /[\\/]/.test(query) + const dot = query.includes(".") + const fast = slash || dot log.info("search", { query, kind }) if (query && fast && kind === "file") { @@ -660,9 +662,16 @@ export namespace File { Fff.files({ cwd: Instance.directory, query, - size: limit, + size: slash ? limit : Math.max(limit * 5, 100), }) - .then((out) => Array.from(new Set(out.items.map((item) => item.relativePath.replaceAll("\\", "/"))))) + .then((out) => { + const rows = Array.from(new Set(out.items.map((item) => item.relativePath.replaceAll("\\", "/")))) + if (slash || !dot) return rows.slice(0, limit) + const name = query.toLowerCase() + const exact = rows.filter((file) => file.split("/").at(-1)?.toLowerCase() === name) + const sort = exact.length ? exact.toSorted((a, b) => a.length - b.length || a.localeCompare(b)) : rows + return sort.slice(0, limit) + }) .catch(() => []), ) if (files.length) {