diff --git a/editor/src/editor.js b/editor/src/editor.js index f6ebf18..c79081b 100644 --- a/editor/src/editor.js +++ b/editor/src/editor.js @@ -157,22 +157,24 @@ function showSearchResultsExtended(element, template, searchTool, query, input, }) } -function formatLineResult(hit) { +function formatLineResult(hits, key) { return [ { - text: "[[" + hit.title + "]]", + text: "[[" + key + "]]", indented: 0, fold: 'open', hidden: false, fleeting: true }, - { - text: hit.line, - indented: 1, - fold: 'open', - hidden: false, - fleeting: true - } + ..._.map(hits, (hit) => { + return { + text: hit.line, + indented: 1, + fold: 'open', + hidden: false, + fleeting: true + } + }) ] } @@ -629,6 +631,7 @@ function Editor(holder, input) { .finally(() => editor.render()) } else { return search.startQuery(res[2]) + .then(hits => _.groupBy(hits, (it) => it.title)) .then(hits => _.flatMap(hits, formatLineResult)) .then(results => editor.replaceChildren(id, results)) .finally(() => editor.render())