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
search should find notes in hidden subtree when hoisted into it
zadam3804d2df8c21
diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.cssindex 4ca958ca57..29b6215350 100644--- a/src/public/stylesheets/style.css+++ b/src/public/stylesheets/style.css@@ -109,6 +109,7 @@ button.close:hover {.icon-action {border: 1px solid transparent;+ padding: 5px;width: 35px;height: 35px;cursor: pointer;diff --git a/src/services/search/expressions/ancestor.js b/src/services/search/expressions/ancestor.jsindex 169c95c6b9..f48e9e59f3 100644--- a/src/services/search/expressions/ancestor.js+++ b/src/services/search/expressions/ancestor.js@@ -14,7 +14,7 @@ class AncestorExp extends Expression {this.ancestorDepthComparator = this.getComparator(ancestorDepth);}- execute(inputNoteSet, executionContext) {+ execute(inputNoteSet, executionContext, searchContext) {const ancestorNote = becca.notes[this.ancestorNoteId];if (!ancestorNote) {diff --git a/src/services/search/expressions/attribute_exists.js b/src/services/search/expressions/attribute_exists.jsindex f91c19b21d..9e8e92f005 100644--- a/src/services/search/expressions/attribute_exists.js+++ b/src/services/search/expressions/attribute_exists.js@@ -13,7 +13,7 @@ class AttributeExistsExp extends Expression {this.prefixMatch = prefixMatch;}- execute(inputNoteSet) {+ execute(inputNoteSet, executionContext, searchContext) {const attrs = this.prefixMatch? becca.findAttributesWithPrefix(this.attributeType, this.attributeName): becca.findAttributes(this.attributeType, this.attributeName);diff --git a/src/services/search/expressions/label_comparison.js b/src/services/search/expressions/label_comparison.jsindex 1a462af74e..79cf8cc3e1 100644--- a/src/services/search/expressions/label_comparison.js+++ b/src/services/search/expressions/label_comparison.js@@ -13,7 +13,7 @@ class LabelComparisonExp extends Expression {this.comparator = comparator;}- execute(inputNoteSet) {+ execute(inputNoteSet, executionContext, searchContext) {const attrs = becca.findAttributes(this.attributeType, this.attributeName);const resultNoteSet = new NoteSet();diff --git a/src/services/search/expressions/note_flat_text.js b/src/services/search/expressions/note_flat_text.jsindex ca5f2c59dd..002992a511 100644--- a/src/services/search/expressions/note_flat_text.js+++ b/src/services/search/expressions/note_flat_text.js@@ -12,7 +12,7 @@ class NoteFlatTextExp extends Expression {this.tokens = tokens;}- execute(inputNoteSet, executionContext) {+ execute(inputNoteSet, executionContext, searchContext) {// has deps on SQL which breaks unit test so needs to be dynamically requiredconst beccaService = require('../../../becca/becca_service');const resultNoteSet = new NoteSet();diff --git a/src/services/search/expressions/or.js b/src/services/search/expressions/or.jsindex 4aabb7a656..2927882af4 100644--- a/src/services/search/expressions/or.js+++ b/src/services/search/expressions/or.js@@ -25,11 +25,11 @@ class OrExp extends Expression {this.subExpressions = subExpressions;}- execute(inputNoteSet, executionContext) {+ execute(inputNoteSet, executionContext, searchContext) {const resultNoteSet = new NoteSet();for (const subExpression of this.subExpressions) {- resultNoteSet.mergeIn(subExpression.execute(inputNoteSet, executionContext));+ resultNoteSet.mergeIn(subExpression.execute(inputNoteSet, executionContext, searchContext));}return resultNoteSet;diff --git a/src/services/search/expressions/property_comparison.js b/src/services/search/expressions/property_comparison.jsindex dc026fdcf7..a53bd5eca7 100644--- a/src/services/search/expressions/property_comparison.js+++ b/src/services/search/expressions/property_comparison.js@@ -5,8 +5,8 @@ const NoteSet = require('../note_set');const buildComparator = require("../services/build_comparator");/**- * Search string is lower cased for case insensitive comparison. But when retrieving properties- * we need case sensitive form so we have this translation object.+ * Search string is lower cased for case-insensitive comparison. But when retrieving properties+ * we need case-sensitive form, so we have this translation object.*/const PROP_MAPPING = {"noteid": "noteId",@@ -53,7 +53,7 @@ class PropertyComparisonExp extends Expression {}}- execute(inputNoteSet, executionContext) {+ execute(inputNoteSet, executionContext, searchContext) {const resNoteSet = new NoteSet();for (const note of inputNoteSet.notes) {diff --git a/src/services/search/expressions/true.js b/src/services/search/expressions/true.jsindex 1ffab8bf1b..fd685cc17b 100644--- a/src/services/search/expressions/true.js+++ b/src/services/search/expressions/true.js@@ -3,7 +3,7 @@const Expression = require('./expression');class TrueExp extends Expression {- execute(inputNoteSet, executionContext) {+ execute(inputNoteSet, executionContext, searchContext) {return inputNoteSet;}}diff --git a/src/services/search/services/search.js b/src/services/search/services/search.jsindex 145200e78b..954817c78f 100644--- a/src/services/search/services/search.js+++ b/src/services/search/services/search.js@@ -151,6 +151,9 @@ function findResultsWithExpression(expression, searchContext) {noteIdToNotePath: {}};+ const ancestorNote = becca.getNote(searchContext.ancestorNoteId || 'root');+ const showNotesInHiddenSubtree = ancestorNote.hasAncestor('_hidden');+const noteSet = expression.execute(allNoteSet, executionContext, searchContext);const searchResults = noteSet.notes@@ -165,7 +168,7 @@ function findResultsWithExpression(expression, searchContext) {throw new Error(`Can't find note path for note ${JSON.stringify(note.getPojo())}`);}- if (notePathArray.includes('_hidden')) {+ if (!showNotesInHiddenSubtree && notePathArray.includes('_hidden')) {return null;}