core: fix notes lookup with non-existent tags

This commit is contained in:
Abdullah Atta
2026-07-21 14:07:10 +05:00
committed by Ammar Ahmed
parent 771a8bb4e3
commit db8408f62f

View File

@@ -155,6 +155,12 @@ export default class Lookup {
? await this.db.notebooks.all.ids()
: [];
if (
(!!tag?.length && tag.length !== tagIds.length) ||
(!!color?.length && color.length !== colorIds.length)
)
return emptySearchResults();
const defaultVault = await this.db.vaults.default();
notes = notes.where((eb) => {
const exprs = [];
@@ -1212,3 +1218,12 @@ function highlightRegexMatches(
function removeDiacritics(s: string) {
return s.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
}
function emptySearchResults() {
return new VirtualizedGrouping<HighlightedResult>(
0,
20,
() => Promise.resolve([]),
() => Promise.resolve({ ids: [], items: [] })
);
}