Skip to content

Commit

Permalink
Remove lineNumber from the lines serialization, fix tests
Browse files Browse the repository at this point in the history
I unwisely used `as const`, thus making the stale test data pass
typechecking for some time.
  • Loading branch information
isker committed Sep 6, 2023
1 parent 389201f commit a095789
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 413 deletions.
10 changes: 2 additions & 8 deletions src/lib/server/search-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,7 @@ const searchResultSchema = v.object({
.filter(({ isFileNameChunk }) => !isFileNameChunk)
.map(({ content, startLineNumber, matchRanges }) => {
const lines = parseChunkMatch(content, matchRanges).map(
(lineTokens, lineOffset) => ({
// TODO this is pretty pointlessly wasteful to put
// in the serialization as it's trivially derivable
// by anything that needs it; remove this and add
// `startLineNumber` to the match serialization
// instead.
lineNumber: startLineNumber + lineOffset,
(lineTokens) => ({
lineTokens,
// While the frontend could derive this from
// lineTokens, counts of matches in a chunk are
Expand All @@ -226,7 +220,7 @@ const searchResultSchema = v.object({
0
);

return { matchCount, lines };
return { matchCount, startLineNumber, lines };
}),
};
}
Expand Down
Loading

0 comments on commit a095789

Please sign in to comment.