Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions apps/server/src/workspace/WorkspaceEntries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,29 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceEntries", (it) => {
}),
);

it.effect("keeps matches past the truncated part of a long line", () =>
Effect.gen(function* () {
const cwd = yield* makeTempDir({ prefix: "t3code-workspace-content-long-line-" });
yield* writeTextFile(cwd, "dist/app.min.js", `${"x".repeat(600)} needleSuffix\n`);

const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
const search = (wholeWord: boolean) =>
workspaceEntries.searchContents({
cwd,
query: "needle",
limit: 100,
caseSensitive: true,
wholeWord,
useRegex: false,
});

expect((yield* search(false)).matches).toEqual([
expect.objectContaining({ path: "dist/app.min.js", lineNumber: 1 }),
]);
expect((yield* search(true)).matches).toEqual([]);
}),
);

it.effect("keeps answering from the live index when a refresh outlasts the scan wait", () =>
Effect.gen(function* () {
const cwd = yield* makeTempDir({ prefix: "t3code-workspace-content-refresh-" });
Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/workspace/WorkspaceSearchIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ export const make = Effect.fn("WorkspaceSearchIndex.make")(function* (
const matchRanges = mapContentMatchRanges(match.lineContent, match.matchRanges).filter(
(range) => !input.wholeWord || isWholeWordRange(match.lineContent, range),
);
if (matchRanges.length === 0) continue;
// fff reports hits past its 512-char lineContent cap with no ranges, so whole words can't be verified there.
if (input.wholeWord && matchRanges.length === 0) continue;
matches.push({
path: toPosixPath(match.relativePath),
lineNumber: match.lineNumber,
Expand Down
Loading