Group {{query:...}} results by page
This commit is contained in:
parent
dec8e85064
commit
707f84ec43
|
@ -157,22 +157,24 @@ function showSearchResultsExtended(element, template, searchTool, query, input,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatLineResult(hit) {
|
function formatLineResult(hits, key) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
text: "[[" + hit.title + "]]",
|
text: "[[" + key + "]]",
|
||||||
indented: 0,
|
indented: 0,
|
||||||
fold: 'open',
|
fold: 'open',
|
||||||
hidden: false,
|
hidden: false,
|
||||||
fleeting: true
|
fleeting: true
|
||||||
},
|
},
|
||||||
{
|
..._.map(hits, (hit) => {
|
||||||
|
return {
|
||||||
text: hit.line,
|
text: hit.line,
|
||||||
indented: 1,
|
indented: 1,
|
||||||
fold: 'open',
|
fold: 'open',
|
||||||
hidden: false,
|
hidden: false,
|
||||||
fleeting: true
|
fleeting: true
|
||||||
}
|
}
|
||||||
|
})
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,6 +631,7 @@ function Editor(holder, input) {
|
||||||
.finally(() => editor.render())
|
.finally(() => editor.render())
|
||||||
} else {
|
} else {
|
||||||
return search.startQuery(res[2])
|
return search.startQuery(res[2])
|
||||||
|
.then(hits => _.groupBy(hits, (it) => it.title))
|
||||||
.then(hits => _.flatMap(hits, formatLineResult))
|
.then(hits => _.flatMap(hits, formatLineResult))
|
||||||
.then(results => editor.replaceChildren(id, results))
|
.then(results => editor.replaceChildren(id, results))
|
||||||
.finally(() => editor.render())
|
.finally(() => editor.render())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user