Merge from vscode ad407028575a77ea387eb7cc219b323dc017b686

This commit is contained in:
ADS Merger
2020-08-22 06:06:52 +00:00
committed by Anthony Dresser
parent 404260b8a0
commit 4ad73d381c
480 changed files with 14360 additions and 14122 deletions

View File

@@ -18,7 +18,11 @@ const bootstrap = require('./bootstrap');
const paths = require('./paths');
/** @type {any} */
const product = require('../product.json');
const { app, protocol } = require('electron');
const { app, protocol, crashReporter } = require('electron');
// Disable render process reuse, we still have
// non-context aware native modules in the renderer.
app.allowRendererProcessReuse = false;
// Enable portable support
const portable = bootstrap.configurePortable(product);
@@ -38,13 +42,13 @@ if (args['nogpu']) { // {{SQL CARBON EDIT}}
const userDataPath = getUserDataPath(args);
app.setPath('userData', userDataPath);
// Set temp directory based on crash-reporter-directory CLI argument
// The crash reporter will store crashes in temp folder so we need
// to change that location accordingly.
// Configure static command line arguments
const argvConfig = configureCommandlineSwitchesSync(args);
// If a crash-reporter-directory is specified we setup the crash reporter
// right from the beginning as early as possible to monitor all processes.
// If a crash-reporter-directory is specified we store the crash reports
// in the specified directory and don't upload them to the crash server.
let crashReporterDirectory = args['crash-reporter-directory'];
let submitURL = '';
if (crashReporterDirectory) {
crashReporterDirectory = path.normalize(crashReporterDirectory);
@@ -62,23 +66,41 @@ if (crashReporterDirectory) {
}
}
// Crashes are stored in the temp directory by default, so we
// Crashes are stored in the crashDumps directory by default, so we
// need to change that directory to the provided one
console.log(`Found --crash-reporter-directory argument. Setting temp directory to be '${crashReporterDirectory}'`);
app.setPath('temp', crashReporterDirectory);
// Start crash reporter
const { crashReporter } = require('electron');
const productName = (product.crashReporter && product.crashReporter.productName) || product.nameShort;
const companyName = (product.crashReporter && product.crashReporter.companyName) || 'Microsoft';
crashReporter.start({
companyName: companyName,
productName: process.env['VSCODE_DEV'] ? `${productName} Dev` : productName,
submitURL: '',
uploadToServer: false
});
console.log(`Found --crash-reporter-directory argument. Setting crashDumps directory to be '${crashReporterDirectory}'`);
app.setPath('crashDumps', crashReporterDirectory);
} else {
const appCenter = product.appCenter;
// Disable Appcenter crash reporting if
// * --crash-reporter-directory is specified
// * enable-crash-reporter runtime argument is set to 'false'
// * --disable-crash-reporter command line parameter is set
if (appCenter && argvConfig['enable-crash-reporter'] && !args['disable-crash-reporter']) {
const isWindows = (process.platform === 'win32');
const isLinux = (process.platform === 'linux');
const crashReporterId = argvConfig['crash-reporter-id'];
const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
if (uuidPattern.test(crashReporterId)) {
submitURL = isWindows ? appCenter[process.arch === 'ia32' ? 'win32-ia32' : 'win32-x64'] : isLinux ? appCenter[`linux-x64`] : appCenter.darwin;
submitURL = submitURL.concat('&uid=', crashReporterId, '&iid=', crashReporterId, '&sid=', crashReporterId);
// Send the id for child node process that are explicitly starting crash reporter.
// For vscode this is ExtensionHost process currently.
process.argv.push('--crash-reporter-id', crashReporterId);
}
}
}
// Start crash reporter for all processes
const productName = (product.crashReporter ? product.crashReporter.productName : undefined) || product.nameShort;
const companyName = (product.crashReporter ? product.crashReporter.companyName : undefined) || 'Microsoft';
crashReporter.start({
companyName: companyName,
productName: process.env['VSCODE_DEV'] ? `${productName} Dev` : productName,
submitURL,
uploadToServer: !crashReporterDirectory
});
// Set logs path before app 'ready' event if running portable
// to ensure that no 'logs' folder is created on disk at a
// location outside of the portable directory
@@ -117,9 +139,6 @@ registerListeners();
// Cached data
const nodeCachedDataDir = getNodeCachedDir();
// Configure static command line arguments
const argvConfig = configureCommandlineSwitchesSync(args);
// Remove env set by snap https://github.com/microsoft/vscode/issues/85344
if (process.env['SNAP']) {
delete process.env['GDK_PIXBUF_MODULE_FILE'];
@@ -261,9 +280,6 @@ function configureCommandlineSwitchesSync(cliArgs) {
app.commandLine.appendSwitch('js-flags', jsFlags);
}
// TODO@Deepak Electron 7 workaround for https://github.com/microsoft/vscode/issues/88873
app.commandLine.appendSwitch('disable-features', 'LayoutNG');
return argvConfig;
}
@@ -304,21 +320,10 @@ function createDefaultArgvConfigSync(argvConfigPath) {
fs.mkdirSync(argvConfigPathDirname);
}
// Migrate over legacy locale
const localeConfigPath = path.join(userDataPath, 'User', 'locale.json');
const legacyLocale = getLegacyUserDefinedLocaleSync(localeConfigPath);
if (legacyLocale) {
try {
fs.unlinkSync(localeConfigPath);
} catch (error) {
//ignore
}
}
// Default argv content
const defaultArgvConfigContent = [
'// This configuration file allows you to pass permanent command line arguments to VS Code.',
'// Only a subset of arguments is currently supported to reduce the likelyhood of breaking',
'// Only a subset of arguments is currently supported to reduce the likelihood of breaking',
'// the installation.',
'//',
'// PLEASE DO NOT CHANGE WITHOUT UNDERSTANDING THE IMPACT',
@@ -331,19 +336,10 @@ function createDefaultArgvConfigSync(argvConfigPath) {
'',
' // Enabled by default by VS Code to resolve color issues in the renderer',
' // See https://github.com/Microsoft/vscode/issues/51791 for details',
' "disable-color-correct-rendering": true'
' "disable-color-correct-rendering": true',
'}'
];
if (legacyLocale) {
defaultArgvConfigContent[defaultArgvConfigContent.length - 1] = `${defaultArgvConfigContent[defaultArgvConfigContent.length - 1]},`; // append trailing ","
defaultArgvConfigContent.push('');
defaultArgvConfigContent.push(' // Display language of VS Code');
defaultArgvConfigContent.push(` "locale": "${legacyLocale}"`);
}
defaultArgvConfigContent.push('}');
// Create initial argv.json with default content
fs.writeFileSync(argvConfigPath, defaultArgvConfigContent.join('\n'));
} catch (error) {
@@ -601,19 +597,4 @@ function getUserDefinedLocale(argvConfig) {
return argvConfig.locale && typeof argvConfig.locale === 'string' ? argvConfig.locale.toLowerCase() : undefined;
}
/**
* @param {string} localeConfigPath
* @returns {string | undefined}
*/
function getLegacyUserDefinedLocaleSync(localeConfigPath) {
try {
const content = stripComments(fs.readFileSync(localeConfigPath).toString());
const value = JSON.parse(content).locale;
return value && typeof value === 'string' ? value.toLowerCase() : undefined;
} catch (error) {
// ignore
}
}
//#endregion