#552 - Fix for content retrieval in multi-root workspaces

This commit is contained in:
Elio Struyf
2023-03-29 17:30:04 +02:00
parent 8054a964b4
commit 3086ca67ce
4 changed files with 28 additions and 6 deletions
+1
View File
@@ -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)
+21 -5
View File
@@ -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);
+4 -1
View File
@@ -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)) {
+2
View File
@@ -7,4 +7,6 @@ export interface ContentFolder {
filePrefix?: string;
contentTypes?: string[];
originalPath?: string;
$schema?: string;
extended?: boolean;
}