diff --git a/docs/releases/unreleased.md b/docs/releases/unreleased.md index b967e6790..5d36191b5 100644 --- a/docs/releases/unreleased.md +++ b/docs/releases/unreleased.md @@ -41,3 +41,4 @@ When a change has user-facing documentation, include a canonical tasknotes.dev l ## Fixed - (#2382) Fixed Kanban settings being ignored in existing `.base` files when nested under `options:` or `config:`, including empty-column hiding and pinned columns. Newly generated default files and exported v3 views now write settings directly on each view; existing files remain unchanged. See [Kanban View](https://tasknotes.dev/views/kanban-view/#configuration). Thanks to @techwiththiru for reporting this. +- (#2390) Fixed the "Add to Project" modal listing notes from folders set in the Excluded folders setting. Thanks to @hikatamika for reporting this. diff --git a/src/modals/ProjectSelectModal.ts b/src/modals/ProjectSelectModal.ts index 8c23aa851..069d76e9e 100644 --- a/src/modals/ProjectSelectModal.ts +++ b/src/modals/ProjectSelectModal.ts @@ -13,6 +13,7 @@ import { getProjectPropertyFilter, matchesProjectProperty } from "../utils/proje import { FilterUtils } from "../utils/FilterUtils"; import { collectCacheTags } from "../utils/tagExtraction"; import { getActiveFolderPath, isPathInIncludedFolders } from "../suggest/FileSuggestHelper"; +import { isPathInExcludedFolder, parseExcludedFolders } from "../utils/pathExclusions"; import { createTaskNotesLogger } from "../utils/tasknotesLogger"; const tasknotesLogger = createTaskNotesLogger({ tag: "Modals/ProjectSelectModal" }); @@ -38,13 +39,15 @@ export class ProjectSelectModal extends FuzzySuggestModal { } getItems(): TAbstractFile[] { + const excludedFolders = parseExcludedFolders(this.plugin.settings?.excludedFolders); const allFiles = this.app.vault .getAllLoadedFiles() .filter( (file) => file instanceof TFile && file.extension === "md" && - !file.path.includes(".trash") + !file.path.includes(".trash") && + !isPathInExcludedFolder(file.path, excludedFolders) ); // Get filtering settings diff --git a/tests/unit/modals/ProjectSelectModal.property-filter.test.ts b/tests/unit/modals/ProjectSelectModal.property-filter.test.ts index c534dd058..39a91de53 100644 --- a/tests/unit/modals/ProjectSelectModal.property-filter.test.ts +++ b/tests/unit/modals/ProjectSelectModal.property-filter.test.ts @@ -99,4 +99,20 @@ describe('ProjectSelectModal property filtering', () => { expect(paths).not.toContain('Projects/Alpha.md'); expect(paths).not.toContain('Notes/Idea.md'); }); + + it('excludes files in the configured excluded folders even without other filters', async () => { + mockPlugin.settings.projectAutosuggest.propertyKey = ''; + mockPlugin.settings.projectAutosuggest.propertyValue = ''; + mockPlugin.settings.excludedFolders = '_src, Notes'; + + await mockApp.vault.create('_src/Hidden.md', ''); + mockApp.metadataCache.setCache('_src/Hidden.md', { frontmatter: {}, tags: [] }); + + const modal = new ProjectSelectModal(mockApp, mockPlugin, jest.fn()); + const paths = modal.getItems().map(item => (item as any).path ?? ''); + + expect(paths).toContain('Projects/Alpha.md'); + expect(paths).not.toContain('_src/Hidden.md'); + expect(paths).not.toContain('Notes/Idea.md'); + }); });