From 4d05c660c83a37544480fe30cee185340f025dae Mon Sep 17 00:00:00 2001 From: Elio Date: Thu, 8 Sep 2022 10:00:38 +0200 Subject: [PATCH] #398: Fix Windows folder path parsing in data folder retrieval --- CHANGELOG.md | 1 + src/commands/Folders.ts | 4 ++-- src/helpers/DashboardSettings.ts | 11 ++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cdc67e7..2fe24301 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ - [#384](https://github.com/estruyf/vscode-front-matter/issues/384): Fix issue `title` field in sub-fields - [#393](https://github.com/estruyf/vscode-front-matter/issues/393): Fix Windows file path for retrieving the preview path - [#396](https://github.com/estruyf/vscode-front-matter/issues/396): Fix for `index` and `_index` page previews +- [#398](https://github.com/estruyf/vscode-front-matter/issues/398): Fix Windows folder path parsing in data folder retrieval ## [8.0.1] - 2022-07-13 diff --git a/src/commands/Folders.ts b/src/commands/Folders.ts index b8678ef7..c12977fd 100644 --- a/src/commands/Folders.ts +++ b/src/commands/Folders.ts @@ -368,7 +368,7 @@ export class Folders { const isWindows = process.platform === 'win32'; let absPath = filePath.replace(WORKSPACE_PLACEHOLDER, parseWinPath(wsFolder?.fsPath || "")); absPath = isWindows ? absPath.split('/').join('\\') : absPath; - return absPath; + return parseWinPath(absPath); } /** @@ -381,7 +381,7 @@ export class Folders { const isWindows = process.platform === 'win32'; let absPath = folder.path.replace(WORKSPACE_PLACEHOLDER, parseWinPath(wsFolder?.fsPath || "")); absPath = isWindows ? absPath.split('/').join('\\') : absPath; - return absPath; + return parseWinPath(absPath); } /** diff --git a/src/helpers/DashboardSettings.ts b/src/helpers/DashboardSettings.ts index bf1aacc2..4afbcfc6 100644 --- a/src/helpers/DashboardSettings.ts +++ b/src/helpers/DashboardSettings.ts @@ -12,6 +12,7 @@ import { DataType } from "../models/DataType"; import { Extension } from "./Extension"; import { FrameworkDetector } from "./FrameworkDetector"; import { Settings } from "./SettingsHelper"; +import { parseWinPath } from './parseWinPath'; export class DashboardSettings { @@ -76,7 +77,7 @@ export class DashboardSettings { * @returns */ private static async getDataFiles(): Promise { - const wsPath = Folders.getWorkspaceFolder()?.fsPath; + const wsPath = parseWinPath(Folders.getWorkspaceFolder()?.fsPath); const files = Settings.get(SETTING_DATA_FILES); const folders = Settings.get(SETTING_DATA_FOLDERS); @@ -92,14 +93,14 @@ export class DashboardSettings { continue; } - let dataFolderPath = join(folderPath.replace((wsPath || ''), '')); + let dataFolderPath = parseWinPath(join(folderPath.replace((wsPath || ''), ''))); if (dataFolderPath.startsWith('/')) { dataFolderPath = dataFolderPath.substring(1); } - const dataJsonFiles = await workspace.findFiles(join(dataFolderPath, '*.json')); - const dataYmlFiles = await workspace.findFiles(join(dataFolderPath, '*.yml')); - const dataYamlFiles = await workspace.findFiles(join(dataFolderPath, '*.yaml')); + const dataJsonFiles = await workspace.findFiles(parseWinPath(join(dataFolderPath, '*.json'))); + const dataYmlFiles = await workspace.findFiles(parseWinPath(join(dataFolderPath, '*.yml'))); + const dataYamlFiles = await workspace.findFiles(parseWinPath(join(dataFolderPath, '*.yaml'))); const dataFiles = [...dataJsonFiles, ...dataYmlFiles, ...dataYamlFiles]; for (let dataFile of dataFiles) {