fix(memory-qmd): restore qmd compatibility defaults

This commit is contained in:
Vincent Koc
2026-04-06 01:31:19 +01:00
parent ca462fb928
commit 098f4eeebb
7 changed files with 51 additions and 10 deletions

View File

@@ -40,6 +40,18 @@ complete`,
]);
});
it("maps single-line qmd line metadata onto both line bounds", () => {
const results = parseQmdQueryJson('[{"docid":"abc","score":0.5,"line":9}]', "");
expect(results).toEqual([
{
docid: "abc",
score: 0.5,
startLine: 9,
endLine: 9,
},
]);
});
it("treats plain-text no-results from stderr as an empty result set", () => {
const results = parseQmdQueryJson("", "No results found\n");
expect(results).toEqual([]);

View File

@@ -89,6 +89,9 @@ function parseQmdQueryResultArray(raw: string): QmdQueryResult[] | null {
const file = typeof record.file === "string" ? record.file : undefined;
const snippet = typeof record.snippet === "string" ? record.snippet : undefined;
const body = typeof record.body === "string" ? record.body : undefined;
const line = parseQmdLineNumber(record.line);
const startLine = parseQmdLineNumber(record.start_line ?? record.startLine) ?? line;
const endLine = parseQmdLineNumber(record.end_line ?? record.endLine) ?? line;
return {
docid,
score,
@@ -96,8 +99,8 @@ function parseQmdQueryResultArray(raw: string): QmdQueryResult[] | null {
file,
snippet,
body,
startLine: parseQmdLineNumber(record.start_line ?? record.startLine),
endLine: parseQmdLineNumber(record.end_line ?? record.endLine),
startLine,
endLine,
} as QmdQueryResult;
});
} catch {