Skip to content

Commit

Permalink
sandbox config - add forceEnableDeveloperKeybindings
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Mar 31, 2021
1 parent 8a4d271 commit 5ec2f69
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
24 changes: 12 additions & 12 deletions src/bootstrap-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* canModifyDOM?: (config: import('./vs/base/parts/sandbox/common/sandboxTypes').ISandboxConfiguration) => void,
* beforeLoaderConfig?: (config: import('./vs/base/parts/sandbox/common/sandboxTypes').ISandboxConfiguration, loaderConfig: object) => void,
* beforeRequire?: () => void
* }} options
* }} [options]
*/
async function load(modulePaths, resultCallback, options) {
performance.mark('code/willWaitForWindowConfig');
Expand All @@ -50,20 +50,20 @@

// Error handler
safeProcess.on('uncaughtException', function (/** @type {string | Error} */ error) {
onUnexpectedError(error, enableDeveloperTools);
onUnexpectedError(error, enableDeveloperKeybindings);
});

// Developer tools
const enableDeveloperTools = (safeProcess.env['VSCODE_DEV'] || !!configuration.extensionDevelopmentPath) && !configuration.extensionTestsPath;
let developerToolsUnbind;
if (enableDeveloperTools || (options && options.forceEnableDeveloperKeybindings)) {
developerToolsUnbind = registerDeveloperKeybindings(options && options.disallowReloadKeybinding);
const enableDeveloperKeybindings = safeProcess.env['VSCODE_DEV'] || configuration.forceEnableDeveloperKeybindings || options?.forceEnableDeveloperKeybindings;
let developerDeveloperKeybindingsDisposable;
if (enableDeveloperKeybindings) {
developerDeveloperKeybindingsDisposable = registerDeveloperKeybindings(options?.disallowReloadKeybinding);
}

// Enable ASAR support
globalThis.MonacoBootstrap.enableASARSupport(configuration.appRoot);

if (options && typeof options.canModifyDOM === 'function') {
if (typeof options?.canModifyDOM === 'function') {
options.canModifyDOM(configuration);
}

Expand Down Expand Up @@ -140,7 +140,7 @@
};
}

if (options && typeof options.beforeLoaderConfig === 'function') {
if (typeof options?.beforeLoaderConfig === 'function') {
options.beforeLoaderConfig(configuration, loaderConfig);
}

Expand All @@ -152,7 +152,7 @@
});
}

if (options && typeof options.beforeRequire === 'function') {
if (typeof options?.beforeRequire === 'function') {
options.beforeRequire();
}

Expand All @@ -171,12 +171,12 @@
if (callbackResult instanceof Promise) {
await callbackResult;

if (developerToolsUnbind && options && options.removeDeveloperKeybindingsAfterLoad) {
developerToolsUnbind();
if (developerDeveloperKeybindingsDisposable && options?.removeDeveloperKeybindingsAfterLoad) {
developerDeveloperKeybindingsDisposable();
}
}
} catch (error) {
onUnexpectedError(error, enableDeveloperTools);
onUnexpectedError(error, enableDeveloperKeybindings);
}
}, onUnexpectedError);
}
Expand Down
3 changes: 1 addition & 2 deletions src/vs/base/parts/sandbox/common/sandboxTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ export interface ISandboxConfiguration {

nodeCachedDataDir?: string;

extensionDevelopmentPath?: string[];
extensionTestsPath?: string;
forceEnableDeveloperKeybindings?: boolean;
}
3 changes: 3 additions & 0 deletions src/vs/platform/windows/electron-main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,9 @@ export class CodeWindow extends Disposable implements ICodeWindow {
release: release()
};

// Developer tools
configuration.forceEnableDeveloperKeybindings = !!((process.env['VSCODE_DEV'] || !!configuration.extensionDevelopmentPath) && !configuration.extensionTestsPath);

// Store into config object URL
this.configObjectUrl.update(configuration);
}
Expand Down

0 comments on commit 5ec2f69

Please sign in to comment.