From 17074eafa1eca7ef7dadcb7fed4c87352a66ebc6 Mon Sep 17 00:00:00 2001 From: Ryan Malia Date: Tue, 7 Apr 2026 11:53:09 -0700 Subject: [PATCH] fix: include line in CLI --json search output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit but that function has no callers — the CLI's outputResults() uses its own inline JSON formatting that destructured only .snippet from extractSnippet(), discarding .line. Extract the full SnippetResult and spread the line field into the JSON output object. Closes #505 --- src/cli/qmd.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cli/qmd.ts b/src/cli/qmd.ts index a09ffb3..c6a66eb 100755 --- a/src/cli/qmd.ts +++ b/src/cli/qmd.ts @@ -1932,7 +1932,8 @@ function outputResults(results: OutputRow[], query: string, opts: OutputOptions) const output = filtered.map(row => { const docid = row.docid || (row.hash ? row.hash.slice(0, 6) : undefined); let body = opts.full ? row.body : undefined; - let snippet = !opts.full ? extractSnippet(row.body, query, 300, row.chunkPos, undefined, opts.intent).snippet : undefined; + const snippetInfo = !opts.full ? extractSnippet(row.body, query, 300, row.chunkPos, undefined, opts.intent) : undefined; + let snippet = snippetInfo?.snippet; if (opts.lineNumbers) { if (body) body = addLineNumbers(body); if (snippet) snippet = addLineNumbers(snippet); @@ -1941,6 +1942,7 @@ function outputResults(results: OutputRow[], query: string, opts: OutputOptions) ...(docid && { docid: `#${docid}` }), score: Math.round(row.score * 100) / 100, file: toQmdPath(row.displayPath), + ...(snippetInfo && { line: snippetInfo.line }), title: row.title, ...(row.context && { context: row.context }), ...(body && { body }),