Update content folder settings

This commit is contained in:
Elio Struyf
2022-03-16 19:55:43 +01:00
parent c09831e832
commit c4331cb140
2 changed files with 22 additions and 5 deletions
+2 -2
View File
@@ -295,7 +295,7 @@ export class Folders {
* Update the folder settings
* @param folders
*/
private static async update(folders: ContentFolder[]) {
public static async update(folders: ContentFolder[]) {
const wsFolder = Folders.getWorkspaceFolder();
let folderDetails = folders.map(folder => ({
@@ -341,7 +341,7 @@ export class Folders {
* @param wsFolder
* @returns
*/
private static relWsFolder(folder: ContentFolder, wsFolder?: Uri) {
public static relWsFolder(folder: ContentFolder, wsFolder?: Uri) {
const isWindows = process.platform === 'win32';
let absPath = parseWinPath(folder.path).replace(parseWinPath(wsFolder?.fsPath || ""), WORKSPACE_PLACEHOLDER);
absPath = isWindows ? absPath.split('\\').join('/') : absPath;
+20 -3
View File
@@ -1,6 +1,8 @@
import { basename } from "path";
import { extensions, Uri, ExtensionContext, window, workspace, commands, ExtensionMode, DiagnosticCollection, languages } from "vscode";
import { EXTENSION_NAME, GITHUB_LINK, SETTING_DATE_FIELD, SETTING_MODIFIED_FIELD, EXTENSION_BETA_ID, EXTENSION_ID, ExtensionState, CONFIG_KEY } from "../constants";
import { Folders } from "../commands/Folders";
import { EXTENSION_NAME, GITHUB_LINK, SETTING_DATE_FIELD, SETTING_MODIFIED_FIELD, EXTENSION_BETA_ID, EXTENSION_ID, ExtensionState, CONFIG_KEY, SETTING_CONTENT_PAGE_FOLDERS } from "../constants";
import { ContentFolder } from "../models";
import { Notifications } from "./Notifications";
import { Settings } from "./SettingsHelper";
@@ -143,7 +145,7 @@ export class Extension {
const publishField = Settings.inspect(SETTING_DATE_FIELD);
const modifiedField = Settings.inspect(SETTING_MODIFIED_FIELD);
// Check for deprecation
// Check for extension deprecations
if (publishField?.workspaceValue ||
publishField?.globalValue ||
publishField?.teamValue ||
@@ -163,7 +165,22 @@ export class Extension {
}
if (major < 7) {
// No migration needed
const contentFolders: ContentFolder[] = Settings.get(SETTING_CONTENT_PAGE_FOLDERS) as ContentFolder[];
const wsFolder = Folders.getWorkspaceFolder();
if (wsFolder) {
let update = false;
for (const cFolder of contentFolders) {
if (cFolder.path.indexOf(wsFolder.fsPath) !== -1) {
update = true;
cFolder.path = Folders.relWsFolder(cFolder, wsFolder);
}
}
if (update) {
Folders.update(contentFolders);
}
}
}
}