mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-07 17:32:58 +02:00
Merge branch 'dev' of github.com:estruyf/vscode-front-matter into dev
This commit is contained in:
+1
-1
@@ -335,7 +335,7 @@
|
||||
},
|
||||
{
|
||||
"command": "frontMatter.unregisterFolder",
|
||||
"when": "explorerResourceIsFolder && resourcePath in frontMatter.registeredFolders",
|
||||
"when": "explorerResourceIsFolder",
|
||||
"group": "Front Matter@3"
|
||||
}
|
||||
],
|
||||
|
||||
+13
-19
@@ -80,8 +80,6 @@ export class Folders {
|
||||
|
||||
Notifications.info(`Folder registered`);
|
||||
}
|
||||
|
||||
Folders.updateVsCodeCtx();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,20 +92,6 @@ export class Folders {
|
||||
folders = folders.filter(f => f.path !== folder.fsPath);
|
||||
await Folders.update(folders);
|
||||
}
|
||||
|
||||
Folders.updateVsCodeCtx();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the registered folders context
|
||||
*/
|
||||
public static updateVsCodeCtx() {
|
||||
const folders = Folders.get();
|
||||
let allFolders: string[] = [];
|
||||
for (const folder of folders) {
|
||||
allFolders = [...allFolders, folder.path]
|
||||
}
|
||||
commands.executeCommand('setContext', CONTEXT.registeredFolders, allFolders);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,11 +198,11 @@ export class Folders {
|
||||
*/
|
||||
public static get(): ContentFolder[] {
|
||||
const config = SettingsHelper.getConfig();
|
||||
const wsPath = Folders.getWorkspaceFolder();
|
||||
const wsFolder = Folders.getWorkspaceFolder();
|
||||
const folders: ContentFolder[] = config.get(SETTINGS_CONTENT_PAGE_FOLDERS) as ContentFolder[];
|
||||
return folders.map(folder => ({
|
||||
title: folder.title,
|
||||
path: folder.path.replace(WORKSPACE_PLACEHOLDER, wsPath?.fsPath || "")
|
||||
path: Folders.absWsFolder(folder, wsFolder)
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -229,6 +213,16 @@ export class Folders {
|
||||
private static async update(folders: ContentFolder[]) {
|
||||
const config = SettingsHelper.getConfig();
|
||||
const wsFolder = Folders.getWorkspaceFolder();
|
||||
await config.update(SETTINGS_CONTENT_PAGE_FOLDERS, folders.map(folder => ({ title: folder.title, path: folder.path.replace(wsFolder?.fsPath || "", WORKSPACE_PLACEHOLDER) })));
|
||||
await config.update(SETTINGS_CONTENT_PAGE_FOLDERS, folders.map(folder => ({ title: folder.title, path: Folders.absWsFolder(folder, wsFolder) })));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the absolute URL for the workspace
|
||||
* @param folder
|
||||
* @param wsFolder
|
||||
* @returns
|
||||
*/
|
||||
private static absWsFolder(folder: ContentFolder, wsFolder?: Uri) {
|
||||
return folder.path.replace(wsFolder?.fsPath || "", WORKSPACE_PLACEHOLDER)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
export const CONTEXT = {
|
||||
canInit: "frontMatterCanInit",
|
||||
canOpenPreview: "frontMatterCanOpenPreview",
|
||||
canOpenDashboard: "frontMatterCanOpenDashboard",
|
||||
registeredFolders: 'frontMatter.registeredFolders'
|
||||
canOpenDashboard: "frontMatterCanOpenDashboard"
|
||||
};
|
||||
@@ -107,8 +107,6 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
const createContent = vscode.commands.registerCommand(COMMAND_NAME.createContent, Folders.create);
|
||||
|
||||
Folders.updateVsCodeCtx();
|
||||
|
||||
// Initialize command
|
||||
Template.init();
|
||||
const projectInit = vscode.commands.registerCommand(COMMAND_NAME.init, async (cb: Function) => {
|
||||
@@ -128,7 +126,6 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
vscode.workspace.onDidChangeConfiguration(() => {
|
||||
Template.init();
|
||||
Preview.init();
|
||||
Folders.updateVsCodeCtx();
|
||||
|
||||
const exView = ExplorerView.getInstance();
|
||||
exView.getSettings();
|
||||
|
||||
@@ -68,7 +68,7 @@ export class Extension {
|
||||
|
||||
const paths = folders.map((folder: any) => ({
|
||||
title: folder.title,
|
||||
path: `${WORKSPACE_PLACEHOLDER}${folder.fsPath.split(projectFolder).slice(1).join('')}`
|
||||
path: `${WORKSPACE_PLACEHOLDER}${folder.fsPath.split(projectFolder).slice(1).join('')}`.split('\\').join('/')
|
||||
}));
|
||||
|
||||
await config.update(`${SETTINGS_CONTENT_PAGE_FOLDERS}`, paths);
|
||||
|
||||
Reference in New Issue
Block a user