Skip to content

Commit

Permalink
Allowing for negation in tag search
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNCatz committed Sep 1, 2023
1 parent 23e808b commit c4e34b6
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -300,6 +318,11 @@ export const containsTags = async (file: TFile, tag: string, exclusive: boolean,
}
}

if(negate)
{
return true;
}

if(!found && exclusive)
{
return false;
Expand Down

0 comments on commit c4e34b6

Please sign in to comment.