Merge pull request #533 from rymalia/fix/json-line-field
This commit is contained in:
commit
414fee520b
@ -1932,7 +1932,8 @@ function outputResults(results: OutputRow[], query: string, opts: OutputOptions)
|
|||||||
const output = filtered.map(row => {
|
const output = filtered.map(row => {
|
||||||
const docid = row.docid || (row.hash ? row.hash.slice(0, 6) : undefined);
|
const docid = row.docid || (row.hash ? row.hash.slice(0, 6) : undefined);
|
||||||
let body = opts.full ? row.body : 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 (opts.lineNumbers) {
|
||||||
if (body) body = addLineNumbers(body);
|
if (body) body = addLineNumbers(body);
|
||||||
if (snippet) snippet = addLineNumbers(snippet);
|
if (snippet) snippet = addLineNumbers(snippet);
|
||||||
@ -1941,6 +1942,7 @@ function outputResults(results: OutputRow[], query: string, opts: OutputOptions)
|
|||||||
...(docid && { docid: `#${docid}` }),
|
...(docid && { docid: `#${docid}` }),
|
||||||
score: Math.round(row.score * 100) / 100,
|
score: Math.round(row.score * 100) / 100,
|
||||||
file: toQmdPath(row.displayPath),
|
file: toQmdPath(row.displayPath),
|
||||||
|
...(snippetInfo && { line: snippetInfo.line }),
|
||||||
title: row.title,
|
title: row.title,
|
||||||
...(row.context && { context: row.context }),
|
...(row.context && { context: row.context }),
|
||||||
...(body && { body }),
|
...(body && { body }),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user