Feedback: Hugo with partial content in modules vs. Dashboard #602

This commit is contained in:
Elio Struyf
2023-07-11 10:53:08 +02:00
parent 4b87430776
commit 8d72f0845a
2 changed files with 24 additions and 2 deletions
+1
View File
@@ -25,6 +25,7 @@
- [#591](https://github.com/estruyf/vscode-front-matter/issues/591): Support for date format in the `datetime` field
- [#593](https://github.com/estruyf/vscode-front-matter/issues/593): Add support for date formatting in the preview path
- [#599](https://github.com/estruyf/vscode-front-matter/issues/599): Add a placeholder when the base panel view is empty
- [#602](https://github.com/estruyf/vscode-front-matter/issues/602): Find content outside the Front Matter workspace folder
### ⚡️ Optimizations
+23 -2
View File
@@ -272,7 +272,8 @@ export class Folders {
for (const folder of folders) {
try {
const folderPath = parseWinPath(folder.path);
let projectStart = parseWinPath(folder.path).replace(wsFolder, '');
// let projectStart = parseWinPath(folder.path).replace(wsFolder, '');
let projectStart = folderPath;
if (typeof projectStart === 'string') {
projectStart = projectStart.replace(/\\/g, '/');
@@ -291,7 +292,8 @@ export class Folders {
filePath = `*${fileType.startsWith('.') ? '' : '.'}${fileType}`;
}
let foundFiles = await workspace.findFiles(filePath, '**/node_modules/**');
let foundFiles = await Folders.findFiles(filePath);
// 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));
@@ -461,6 +463,11 @@ export class Folders {
const isWindows = process.platform === 'win32';
let absPath = folder.path.replace(WORKSPACE_PLACEHOLDER, parseWinPath(wsFolder?.fsPath || ''));
absPath = isWindows ? absPath.split('/').join('\\') : absPath;
if (absPath.includes('../')) {
absPath = join(absPath);
}
return parseWinPath(absPath);
}
@@ -577,4 +584,18 @@ export class Folders {
});
});
}
/**
* Find all files
* @param pattern
* @returns
*/
private static async findFiles(pattern: string): Promise<Uri[]> {
return new Promise((resolve) => {
glob(pattern, { ignore: '**/node_modules/**' }, (err, files) => {
const allFiles = files.map((file) => Uri.file(file));
resolve(allFiles);
});
});
}
}