Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deactivate Compact Folders fix code #165

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**
JoernBerkefeld marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions src/devtools/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ async function initDevToolsExtension(): Promise<void>{

editorDependencies.activateExtensionDependencies(mainConfig.extensionsDependencies);

// Deactivates Compact folders for command right execution
editorDependencies.deactivateCompactFolders();
JoernBerkefeld marked this conversation as resolved.
Show resolved Hide resolved

// activate the status bar
devtoolsContainers.activateStatusBar();

Expand Down
19 changes: 15 additions & 4 deletions src/editor/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ async function activateExtensionDependencies(dependencies: string | string[]){

if(missingExtDependencies.length){

const suggestRecommendedExtensions: string | boolean =
editorWorkspace.handleWorkspaceConfiguration("recommendExtensions", true).get();
const workspaceConfiguration = editorWorkspace.handleWorkspaceConfiguration("sfmc-devtools-vscode", "Global");
const suggestRecommendedExtensions: boolean =
Boolean(workspaceConfiguration.get("recommendExtensions", true));

if(suggestRecommendedExtensions){
const message: string = "There are some recommended extensions that can enhance your usage of SFMC DevTools. Would you like to install them?";
Expand All @@ -34,15 +35,25 @@ async function activateExtensionDependencies(dependencies: string | string[]){
);
});
}else if(selectedOption === RecommendedExtensionsInputOptions.DONT_ASK_AGAIN){
editorWorkspace.handleWorkspaceConfiguration("recommendExtensions", false).set();
workspaceConfiguration.set("recommendExtensions", false);
}
}
}
}
}

function deactivateCompactFolders(){
const workspaceConfiguration = editorWorkspace.handleWorkspaceConfiguration("explorer", "Workspace");
const isCompactFoldersEnabled: boolean = Boolean(workspaceConfiguration.get("compactFolders", true));
if(isCompactFoldersEnabled){
// Disable Compact Folders
workspaceConfiguration.set("compactFolders", false);
}
}

const editorDependencies = {
activateExtensionDependencies
activateExtensionDependencies,
deactivateCompactFolders
};

export { editorDependencies };
10 changes: 6 additions & 4 deletions src/editor/workspace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { workspace, Uri, TextDocument, WorkspaceFolder, FileType, FileStat, WorkspaceConfiguration, ConfigurationTarget } from "vscode";
import { editorCommands } from "./commands";

type WorkspaceConfigurationTarget = "Global" | "Workspace" | "WorkspaceFolder";

function getWorkspaceURI(): Uri {
const wsFolder: readonly WorkspaceFolder[] | undefined = workspace.workspaceFolders;
if(wsFolder){
Expand Down Expand Up @@ -53,12 +55,12 @@ async function isFile(file: string | Uri){
return fileType.toLowerCase() === "file";
}

function handleWorkspaceConfiguration(key: string, value: string | boolean){
const workspaceConfiguration: WorkspaceConfiguration = workspace.getConfiguration("sfmc-devtools-vscode");
function handleWorkspaceConfiguration(section: string, target: WorkspaceConfigurationTarget){
const workspaceConfiguration: WorkspaceConfiguration = workspace.getConfiguration(section);
if(workspaceConfiguration){
return {
get: () => workspaceConfiguration.get(key, value),
set: () => workspaceConfiguration.update(key, value, ConfigurationTarget.Global)
get: (key: string, value: string | boolean) => workspaceConfiguration.get(key, value),
set: (key: string, value: string | boolean) => workspaceConfiguration.update(key, value, ConfigurationTarget[target])
};
}
throw new Error("Failed to handle Workspace Configuration.");
Expand Down
Loading