Skip to content

Commit

Permalink
fix: #66
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyloong committed Nov 12, 2024
1 parent 7021109 commit 85dc087
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"author": "lazyloong",

"minAppVersion": "1.0.0",
"version": "2.27.6"
"version": "2.27.7"
}
28 changes: 14 additions & 14 deletions src/modal/fileModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default class FileModal extends FuzzyModal<Item> {
return (
tagArray &&
tagArray.length != 0 &&
tagArray.every((tag) => this.tags.some((t) => tag.startsWith(t)))
tagArray.some((tag) => this.tags.some((t) => tag.startsWith(t)))
);
})
.map((p) => ({
Expand Down Expand Up @@ -276,7 +276,7 @@ export default class FileModal extends FuzzyModal<Item> {
result = result.filter((matchData) => {
if (!matchData.item.file) return;
let tagArray = getFileTagArray(matchData.item.file);
return tagArray?.every((tag) => this.tags.some((t) => tag.startsWith(t)));
return tagArray?.some((tag) => this.tags.some((t) => tag.startsWith(t)));
});
}
return result;
Expand Down Expand Up @@ -636,18 +636,18 @@ function openItem(leaf: WorkspaceLeaf, item: Item) {
}

function getFileTagArray(file: TFile): string[] | undefined {
let tags: string | Array<string> =
app.metadataCache.getFileCache(file)?.frontmatter?.tags ||
app.metadataCache.getFileCache(file)?.frontmatter?.tag,
tagArray: string[];
if (tags)
tagArray = Array.isArray(tags)
? tags
: tags
.split(",")
.filter((p) => p)
.map((p) => p.trim());
return tagArray;
let tags: string | string[] | Object =
app.metadataCache.getFileCache(file)?.frontmatter?.tags ||
app.metadataCache.getFileCache(file)?.frontmatter?.tag;
if (!tags) return undefined;

if (Array.isArray(tags)) return tags;
else if (typeof tags == "string")
return tags
.split(/[, ]/)
.filter((p) => p)
.map((p) => p.trim());
else if (typeof tags == "object") return undefined;
}

export const openFileKeyMap: Record<string, () => WorkspaceLeaf> = {
Expand Down

0 comments on commit 85dc087

Please sign in to comment.