Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
autocomplete returns items which have at least one of the tokens in the leaf note title, closes #59
azivner4acc5432c3cf
diff --git a/src/public/javascripts/init.js b/src/public/javascripts/init.jsindex c2700afdad..f0e25a28b6 100644--- a/src/public/javascripts/init.js+++ b/src/public/javascripts/init.js@@ -114,23 +114,33 @@ $.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;}- if (found) {- results.push(item);+ // 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 (results.length > 100) {- break;+ if (!foundInLastSegment) {+ continue;}}++ results.push(item);++ if (results.length > 100) {+ break;+ }}console.log("Search took " + (new Date().getTime() - startDate.getTime()) + "ms");diff --git a/src/public/libraries/codemirror/addon/lint/eslint.js b/src/public/libraries/codemirror/addon/lint/eslint.jsindex 210f1d0963..a1520134b1 100644--- a/src/public/libraries/codemirror/addon/lint/eslint.js+++ b/src/public/libraries/codemirror/addon/lint/eslint.js@@ -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) {