()
| 38 | } |
| 39 | |
| 40 | getItems(): TAbstractFile[] { |
| 41 | const allFiles = this.app.vault |
| 42 | .getAllLoadedFiles() |
| 43 | .filter( |
| 44 | (file) => |
| 45 | file instanceof TFile && |
| 46 | file.extension === "md" && |
| 47 | !file.path.includes(".trash") |
| 48 | ); |
| 49 | |
| 50 | // Get filtering settings |
| 51 | const requiredTags = this.plugin.settings?.projectAutosuggest?.requiredTags ?? []; |
| 52 | const includeFolders = this.plugin.settings?.projectAutosuggest?.includeFolders ?? []; |
| 53 | const propertyFilter = getProjectPropertyFilter(this.plugin.settings?.projectAutosuggest); |
| 54 | const activeFolder = getActiveFolderPath(this.plugin); |
| 55 | |
| 56 | // Apply filtering if any filters are configured |
| 57 | if (requiredTags.length === 0 && includeFolders.length === 0 && !propertyFilter.enabled) { |
| 58 | return allFiles; // No filtering needed |
| 59 | } |
| 60 | |
| 61 | return allFiles.filter((file) => { |
| 62 | if (!(file instanceof TFile)) return false; |
| 63 | |
| 64 | const cache = this.app.metadataCache.getFileCache(file); |
| 65 | |
| 66 | // Apply tag filtering - use FilterUtils for consistent hierarchical tag matching |
| 67 | if (requiredTags.length > 0) { |
| 68 | // Use FilterUtils.matchesTagConditions for hierarchical matching and exclusion support |
| 69 | if (!FilterUtils.matchesTagConditions(collectCacheTags(cache), requiredTags)) { |
| 70 | return false; // Skip this file |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | // Apply folder filtering |
| 75 | if (includeFolders.length > 0) { |
| 76 | if (!isPathInIncludedFolders(file.path, includeFolders, activeFolder)) { |
| 77 | return false; // Skip this file |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | if (propertyFilter.enabled) { |
| 82 | const frontmatter = cache?.frontmatter; |
| 83 | if (!matchesProjectProperty(frontmatter, propertyFilter)) { |
| 84 | return false; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | return true; // File passed all filters |
| 89 | }); |
| 90 | } |
| 91 | |
| 92 | getItemText(file: TAbstractFile): string { |
| 93 | if (!(file instanceof TFile)) { |
nothing calls this directly
no test coverage detected