diff --git a/src/main.js b/src/main.js index 2cb1125288f..3ce8dcbe443 100644 --- a/src/main.js +++ b/src/main.js @@ -201,30 +201,45 @@ function configureCommandlineSwitchesSync(cliArgs) { SUPPORTED_ELECTRON_SWITCHES.push('force-renderer-accessibility'); } + const SUPPORTED_MAIN_PROCESS_SWITCHES = [ + + // Persistently enable proposed api via argv.json: https://github.com/microsoft/vscode/issues/99775 + 'enable-proposed-api' + ]; + // Read argv config const argvConfig = readArgvConfigSync(); - // Append each flag to Electron Object.keys(argvConfig).forEach(argvKey => { - if (SUPPORTED_ELECTRON_SWITCHES.indexOf(argvKey) === -1) { - return; // unsupported argv key - } - const argvValue = argvConfig[argvKey]; - // Color profile - if (argvKey === 'force-color-profile') { - if (argvValue) { - app.commandLine.appendSwitch(argvKey, argvValue); + // Append Electron flags to Electron + if (SUPPORTED_ELECTRON_SWITCHES.indexOf(argvKey) !== -1) { + // Color profile + if (argvKey === 'force-color-profile') { + if (argvValue) { + app.commandLine.appendSwitch(argvKey, argvValue); + } + } + + // Others + else if (argvValue === true || argvValue === 'true') { + if (argvKey === 'disable-hardware-acceleration') { + app.disableHardwareAcceleration(); // needs to be called explicitly + } else { + app.commandLine.appendSwitch(argvKey); + } } } - // Others - else if (argvValue === true || argvValue === 'true') { - if (argvKey === 'disable-hardware-acceleration') { - app.disableHardwareAcceleration(); // needs to be called explicitly - } else { - app.commandLine.appendSwitch(argvKey); + // Append main process flags to process.argv + else if (SUPPORTED_MAIN_PROCESS_SWITCHES.indexOf(argvKey) !== -1) { + if (argvKey === 'enable-proposed-api') { + if (Array.isArray(argvValue)) { + argvValue.forEach(id => id && typeof id === 'string' && process.argv.push('--enable-proposed-api', id)); + } else { + console.error(`Unexpected value for \`enable-proposed-api\` in argv.json. Expected array of extension ids.`); + } } } }); diff --git a/src/vs/workbench/electron-sandbox/desktop.contribution.ts b/src/vs/workbench/electron-sandbox/desktop.contribution.ts index 98a5a69a614..87280ecbcec 100644 --- a/src/vs/workbench/electron-sandbox/desktop.contribution.ts +++ b/src/vs/workbench/electron-sandbox/desktop.contribution.ts @@ -343,6 +343,13 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema'; 'force-color-profile': { type: 'string', markdownDescription: nls.localize('argv.forceColorProfile', 'Allows to override the color profile to use. If you experience colors appear badly, try to set this to `srgb` and restart.') + }, + 'enable-proposed-api': { + type: 'array', + description: nls.localize('argv.enebleProposedApi', "Enable proposed APIs for a list of extension ids (such as \`vscode.git\`). Proposed APIs are unstable and subject to breaking without warning at any time. This should only be set for extension development and testing purposes."), + items: { + type: 'string' + } } } };