Tweaked the foundWords array for #85

This commit is contained in:
Simon Cambier
2022-07-25 20:23:03 +02:00
parent 7900d87c25
commit 48a41fe07f

View File

@@ -266,10 +266,20 @@ export async function getSuggestions(
// Clean search matches that match quoted expressions, // Clean search matches that match quoted expressions,
// and inject those expressions instead // and inject those expressions instead
const foundWords = [ const foundWords = [
...Object.keys(result.match).filter(w => // Matching terms from the result,
query.segments.some(s => w.startsWith(s.value)), // do not necessarily match the query
), ...Object.keys(result.match),
// // Matching terms from the query,
// // but only if they stem from the result's matches
// ...Object.keys(result.match).filter(w =>
// query.segments.some(s => w.startsWith(s.value)),
// ),
// Quoted expressions
...query.segments.filter(s => s.exact).map(s => s.value), ...query.segments.filter(s => s.exact).map(s => s.value),
// Tags, starting with #
...tags, ...tags,
] ]