Skip to content
Source
Sign inSign up
pingdotgg/t3code

Add global project content search #4007

Closedjakeleventhal(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/4007/headopened View on GitHub

Showing 25 changed files with 162 additions and 1 deletion (loading 22).

x
0 of 25 viewed, 25 left
124 additions and 0 deletionsapps/server/src/workspace/WorkspaceEntries.test.tsModified
View file
@@ -292,6 +292,130 @@
});
​
+ describe("searchContents", () => {
+ it.effect("returns content matches with file paths, line numbers, and ranges", () =>
+ Effect.gen(function* () {
+ const cwd = yield* makeTempDir({ prefix: "t3code-workspace-content-search-" });
+ yield* writeTextFile(
+ cwd,
+ "src/shapes.ts",
+ "export const square = 4;\nexport const Square = 16;\nexport const squareSize = 8;\n",
+ );
+ yield* writeTextFile(cwd, "src/other.ts", "const circle = true;\n");
+​
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
+ const result = yield* workspaceEntries.searchContents({
+ cwd,
+ query: "Square",
+ limit: 100,
+ caseSensitive: false,
+ wholeWord: true,
+ useRegex: false,
+ });
+​
+ expect(result.matches.map((match) => [match.path, match.lineNumber])).toEqual([
+ ["src/shapes.ts", 1],
+ ["src/shapes.ts", 2],
+ ]);
+ expect(result.matches[0]?.matchRanges).toEqual([{ start: 13, end: 19 }]);