Skip to content

Commit 1717ca4

Browse files
saphidclaude
andcommitted
fix(server): project content search finds matches past a line's first 512 characters
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d01b92c commit 1717ca4

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎apps/server/src/workspace/WorkspaceEntries.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,29 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceEntries", (it) => {
675675
}),
676676
);
677677

678+
it.effect("keeps matches past the truncated part of a long line", () =>
679+
Effect.gen(function* () {
680+
const cwd = yield* makeTempDir({ prefix: "t3code-workspace-content-long-line-" });
681+
yield* writeTextFile(cwd, "dist/app.min.js", `${"x".repeat(600)} needleSuffix\n`);
682+
683+
const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
684+
const search = (wholeWord: boolean) =>
685+
workspaceEntries.searchContents({
686+
cwd,
687+
query: "needle",
688+
limit: 100,
689+
caseSensitive: true,
690+
wholeWord,
691+
useRegex: false,
692+
});
693+
694+
expect((yield* search(false)).matches).toEqual([
695+
expect.objectContaining({ path: "dist/app.min.js", lineNumber: 1 }),
696+
]);
697+
expect((yield* search(true)).matches).toEqual([]);
698+
}),
699+
);
700+
678701
it.effect("keeps answering from the live index when a refresh outlasts the scan wait", () =>
679702
Effect.gen(function* () {
680703
const cwd = yield* makeTempDir({ prefix: "t3code-workspace-content-refresh-" });

‎apps/server/src/workspace/WorkspaceSearchIndex.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ export const make = Effect.fn("WorkspaceSearchIndex.make")(function* (
505505
const matchRanges = mapContentMatchRanges(match.lineContent, match.matchRanges).filter(
506506
(range) => !input.wholeWord || isWholeWordRange(match.lineContent, range),
507507
);
508-
if (matchRanges.length === 0) continue;
508+
// fff reports hits past its 512-char lineContent cap with no ranges, so whole words can't be verified there.
509+
if (input.wholeWord && matchRanges.length === 0) continue;
509510
matches.push({
510511
path: toPosixPath(match.relativePath),
511512
lineNumber: match.lineNumber,

0 commit comments

Comments
 (0)