mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
autocomplete returns items which have at least one of the tokens in the leaf note title, closes #59
This commit is contained in:
parent
08b8141fdf
commit
4acc5432c3
@ -114,22 +114,32 @@ $.ui.autocomplete.filter = (array, terms) => {
|
||||
const tokens = terms.toLowerCase().split(" ");
|
||||
|
||||
for (const item of array) {
|
||||
let found = true;
|
||||
const lcLabel = item.label.toLowerCase();
|
||||
|
||||
for (const token of tokens) {
|
||||
if (lcLabel.indexOf(token) === -1) {
|
||||
found = false;
|
||||
break;
|
||||
const found = tokens.every(token => lcLabel.indexOf(token) !== -1);
|
||||
if (!found) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// this is not completely correct and might cause minor problems with note with names containing this " / "
|
||||
const lastSegmentIndex = lcLabel.lastIndexOf(" / ");
|
||||
|
||||
if (lastSegmentIndex !== -1) {
|
||||
const lastSegment = lcLabel.substr(lastSegmentIndex + 3);
|
||||
|
||||
// at least some token needs to be in the last segment (leaf note), otherwise this
|
||||
// particular note is not that interesting (query is satisfied by parent note)
|
||||
const foundInLastSegment = tokens.some(token => lastSegment.indexOf(token) !== -1);
|
||||
|
||||
if (!foundInLastSegment) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
results.push(item);
|
||||
results.push(item);
|
||||
|
||||
if (results.length > 100) {
|
||||
break;
|
||||
}
|
||||
if (results.length > 100) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
async function validator(text, options) {
|
||||
async function validator(text, options) {console.log("Validating...");
|
||||
await requireLibrary(ESLINT);
|
||||
|
||||
var errors = new eslint().verify(text, {
|
||||
@ -48,6 +48,8 @@
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper("lint", "javascript", validator);
|
||||
// CodeMirror.registerHelper("lint", "htmlmixed", validator);
|
||||
// CodeMirror.registerHelper("lint", "html", validator);
|
||||
|
||||
function parseErrors(errors, output) {
|
||||
for (const error of errors) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user