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
fix inQuotes + tests
zadam4e5ddaf7d12c
diff --git a/spec/search/lexer.spec.js b/spec/search/lexer.spec.jsindex 1fc918259e..3d259d3081 100644--- a/spec/search/lexer.spec.js+++ b/spec/search/lexer.spec.js@@ -49,6 +49,22 @@ describe("Lexer expression", () => {.toEqual(["#label", "*=*", "text"]);});+ it("simple label operator with in quotes and without", () => {+ expect(lexer("#label*=*'text'").expressionTokens)+ .toEqual([+ {token: "#label", inQuotes: false},+ {token: "*=*", inQuotes: false},+ {token: "text", inQuotes: true}+ ]);++ expect(lexer("#label*=*text").expressionTokens)+ .toEqual([+ {token: "#label", inQuotes: false},+ {token: "*=*", inQuotes: false},+ {token: "text", inQuotes: false}+ ]);+ });+it("complex expressions with and, or and parenthesis", () => {expect(lexer(`# (#label=text OR #second=text) AND ~relation`).expressionTokens.map(t => t.token)).toEqual(["#", "(", "#label", "=", "text", "or", "#second", "=", "text", ")", "and", "~relation"]);diff --git a/src/services/search/lexer.js b/src/services/search/lexer.jsindex cd45f74212..fb6f09e4d1 100644--- a/src/services/search/lexer.js+++ b/src/services/search/lexer.js@@ -28,7 +28,7 @@ function lexer(str) {const rec = {token: currentWord,- inQuotes: quotes+ inQuotes: !!quotes};if (fulltextEnded) {@@ -71,9 +71,9 @@ function lexer(str) {}}else if (quotes === chr) {- quotes = false;-finishWord();++ quotes = false;}else {// it's a quote but within other kind of quotes so it's valid as a literal character