diff --git a/CHANGELOG.md b/CHANGELOG.md index a212d511..321ac0f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ - [#539](https://github.com/estruyf/vscode-front-matter/issues/539): Fix the override of the default file prefix on content creation - [#543](https://github.com/estruyf/vscode-front-matter/issues/543): Fix JSON schema for script commands - [#547](https://github.com/estruyf/vscode-front-matter/issues/547): Fix setting default value in a hidden group field (`block`) +- [#552](https://github.com/estruyf/vscode-front-matter/issues/552): Fix for content retrieval in multi-root workspaces ## [8.3.0] - 2023-02-14 - [Release notes](https://beta.frontmatter.codes/updates/v8.3.0) diff --git a/src/commands/Folders.ts b/src/commands/Folders.ts index e5ed17f0..6bd6c776 100644 --- a/src/commands/Folders.ts +++ b/src/commands/Folders.ts @@ -271,6 +271,7 @@ export class Folders { for (const folder of folders) { try { + const folderPath = parseWinPath(folder.path); let projectStart = parseWinPath(folder.path).replace(wsFolder, ''); if (typeof projectStart === 'string') { @@ -290,7 +291,10 @@ export class Folders { filePath = `*${fileType.startsWith('.') ? '' : '.'}${fileType}`; } - const foundFiles = await workspace.findFiles(filePath, '**/node_modules/**'); + let foundFiles = await workspace.findFiles(filePath, '**/node_modules/**'); + // Make sure these file are coming from the folder path (this could be an issue in multi-root workspaces) + foundFiles = foundFiles.filter((f) => parseWinPath(f.fsPath).startsWith(folderPath)); + files = [...files, ...foundFiles]; } @@ -391,10 +395,22 @@ export class Folders { public static async update(folders: ContentFolder[]) { const wsFolder = Folders.getWorkspaceFolder(); - const folderDetails = folders.map((folder) => ({ - ...folder, - path: Folders.relWsFolder(folder, wsFolder) - })); + const folderDetails = folders + .map((folder) => { + const detail = { + ...folder, + path: Folders.relWsFolder(folder, wsFolder) + }; + + if (detail['$schema'] || detail.extended) { + return null; + } + + delete detail.originalPath; + + return detail; + }) + .filter((folder) => folder !== null); await Settings.update(SETTING_CONTENT_PAGE_FOLDERS, folderDetails, true); diff --git a/src/helpers/SettingsHelper.ts b/src/helpers/SettingsHelper.ts index 29469ee3..680c44d6 100644 --- a/src/helpers/SettingsHelper.ts +++ b/src/helpers/SettingsHelper.ts @@ -674,7 +674,10 @@ export class Settings { } // Page folders else if (Settings.isEqualOrStartsWith(relSettingName, SETTING_CONTENT_PAGE_FOLDERS)) { - Settings.updateGlobalConfigArraySetting(SETTING_CONTENT_PAGE_FOLDERS, 'path', configJson); + Settings.updateGlobalConfigArraySetting(SETTING_CONTENT_PAGE_FOLDERS, 'path', { + ...configJson, + extended: true + }); } // Placeholders else if (Settings.isEqualOrStartsWith(relSettingName, SETTING_CONTENT_PLACEHOLDERS)) { diff --git a/src/models/ContentFolder.ts b/src/models/ContentFolder.ts index 9f65d361..74e9e8d5 100644 --- a/src/models/ContentFolder.ts +++ b/src/models/ContentFolder.ts @@ -7,4 +7,6 @@ export interface ContentFolder { filePrefix?: string; contentTypes?: string[]; originalPath?: string; + $schema?: string; + extended?: boolean; }