From 583fbf4e950edf3ff70e0c8d84555f452c63ff60 Mon Sep 17 00:00:00 2001 From: abaevbog Date: Fri, 14 Mar 2025 04:33:08 -0700 Subject: [PATCH] citation dialog: stricter non-sql item search (#5109) While filtering selected/open/cited items, include items that match EVERY word from the search string, as opposed to items that match ANY of the searched words. Fixes: #5099 --- .../integration/citationDialog/searchHandler.mjs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/integration/citationDialog/searchHandler.mjs b/chrome/content/zotero/integration/citationDialog/searchHandler.mjs index bd341dde43..872f5928a0 100644 --- a/chrome/content/zotero/integration/citationDialog/searchHandler.mjs +++ b/chrome/content/zotero/integration/citationDialog/searchHandler.mjs @@ -269,11 +269,13 @@ export class CitationDialogSearchHandler { let itemStr = item.getCreators() .map(creator => creator.firstName + " " + creator.lastName) .concat([item.getField("title"), item.getField("date", true, true).substr(0, 4)]) - .join(" "); + .join(" ") + .toLowerCase(); - // See if words match - for (let split of splits) { - if (itemStr.toLowerCase().includes(split)) matchedItems.add(item); + // Include items that match every word that was typed + let allMatch = splits.every(split => itemStr.includes(split)); + if (allMatch) { + matchedItems.add(item); } } return Array.from(matchedItems);