Skip to content

Commit

Permalink
fixed tag exclusion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis Kafieh committed Nov 13, 2024
1 parent 1f02af9 commit 08799aa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/logic/file_tracking/fileMatchesCriteria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Settings } from "../../interfaces/Settings";
export default function fileMatchesCriteria(
file: File,
allTags: string[] | null,
settings: Settings,
settings: Settings
) {
// check tags
if (allTags) {
Expand Down
1 change: 1 addition & 0 deletions src/logic/log_note/getFill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function getFill(context: Context) {
const modified = [];
const deleted = [];
const trackedFiles = settings.trackedFiles;

for (const trackedFile of trackedFiles) {
if (!trackedFile.matchesCriteria || !trackedFile.path) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/obsidian/listeners/onMetadataCacheChanged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const onMetadataCacheChanged = serialize(

const matchesCriteria = fileMatchesCriteria(
file,
getAllTags(cache),
getAllTags(cache)?.map((tag) => tag.substring(1)) || null,
settings
);

Expand Down
10 changes: 10 additions & 0 deletions tests/logic/file_tracking/fileMatchesCriteria.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ describe("fileMatchesCriteria should correctly match ignored name text", () => {
)
).toBe(false);
});

it("should fail on name if matching one, combined with other text", () => {
expect(
fileMatchesCriteria(
getSingleFileWithPath("a-abcaa.md"),
[""],
new TestSettingsBuilder().setIgnoredNameContains("abc").build()
)
).toBe(false);
});
});

describe("fileMatchesCriteria should correctly match ignored folder/path", () => {
Expand Down

0 comments on commit 08799aa

Please sign in to comment.