mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
search should find notes in hidden subtree when hoisted into it
This commit is contained in:
parent
7147cc267e
commit
3804d2df8c
@ -109,6 +109,7 @@ button.close:hover {
|
||||
|
||||
.icon-action {
|
||||
border: 1px solid transparent;
|
||||
padding: 5px;
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
cursor: pointer;
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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 required
|
||||
const beccaService = require('../../../becca/becca_service');
|
||||
const resultNoteSet = new NoteSet();
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
const Expression = require('./expression');
|
||||
|
||||
class TrueExp extends Expression {
|
||||
execute(inputNoteSet, executionContext) {
|
||||
execute(inputNoteSet, executionContext, searchContext) {
|
||||
return inputNoteSet;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user