From c4e34b643c7f48e21d6078b7dde359d01171ca82 Mon Sep 17 00:00:00 2001 From: Tom Norris Date: Thu, 31 Aug 2023 23:35:15 -0700 Subject: [PATCH] Allowing for negation in tag search --- src/utils.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 4eb41e2..ce688ab 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -286,11 +286,29 @@ export const containsTags = async (file: TFile, tag: string, exclusive: boolean, for(let k = 0; k < filterTags.length; k++) { + let negate: boolean = false; + let tag = filterTags[k]; + if(tag[0] == '-') + { + tag = tag.substring(1); + negate = true; + } + + if(tag == "") + { + continue; + } + let found: boolean = false; for(let i = 0; i < imgTags.length; i++) { - if(imgTags[i].contains(filterTags[k])) + if(imgTags[i].contains(tag)) { + if(negate) + { + return false; + } + if(!exclusive) { return true; @@ -300,6 +318,11 @@ export const containsTags = async (file: TFile, tag: string, exclusive: boolean, } } + if(negate) + { + return true; + } + if(!found && exclusive) { return false;