Merge from vscode e3c4990c67c40213af168300d1cfeb71d680f877 (#16569)

This commit is contained in:
Cory Rivera
2021-08-25 16:28:29 -07:00
committed by GitHub
parent ab1112bfb3
commit cb7b7da0a4
1752 changed files with 59525 additions and 33878 deletions

View File

@@ -47,6 +47,9 @@ if (args['nogpu']) { // {{SQL CARBON EDIT}}
const userDataPath = getUserDataPath(args);
app.setPath('userData', userDataPath);
// Resolve code cache path
const codeCachePath = getCodeCachePath();
// Configure static command line arguments
const argvConfig = configureCommandlineSwitchesSync(args);
@@ -78,9 +81,6 @@ protocol.registerSchemesAsPrivileged([
// Global app listeners
registerListeners();
// Cached data
const nodeCachedDataDir = getNodeCachedDir();
/**
* Support user defined locale: load it early before app('ready')
* to have more things running in parallel.
@@ -115,14 +115,14 @@ app.once('ready', function () {
/**
* Main startup routine
*
* @param {string | undefined} cachedDataDir
* @param {string | undefined} codeCachePath
* @param {NLSConfiguration} nlsConfig
*/
function startup(cachedDataDir, nlsConfig) {
function startup(codeCachePath, nlsConfig) {
nlsConfig._languagePackSupport = true;
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfig);
process.env['VSCODE_NODE_CACHED_DATA_DIR'] = cachedDataDir || '';
process.env['VSCODE_CODE_CACHE_PATH'] = codeCachePath || '';
// Load main in AMD
perf.mark('code/willLoadMainBundle');
@@ -135,9 +135,9 @@ async function onReady() {
perf.mark('code/mainAppReady');
try {
const [cachedDataDir, nlsConfig] = await Promise.all([nodeCachedDataDir.ensureExists(), resolveNlsConfiguration()]);
const [, nlsConfig] = await Promise.all([mkdirpIgnoreError(codeCachePath), resolveNlsConfiguration()]);
startup(cachedDataDir, nlsConfig);
startup(codeCachePath, nlsConfig);
} catch (error) {
console.error(error);
}
@@ -181,7 +181,7 @@ function configureCommandlineSwitchesSync(cliArgs) {
// Read argv config
const argvConfig = readArgvConfigSync();
let browserCodeLoadingStrategy = undefined;
let browserCodeLoadingStrategy = undefined; // {{SQL CARBON EDIT}} Set to undefined by default
Object.keys(argvConfig).forEach(argvKey => {
const argvValue = argvConfig[argvKey];
@@ -266,7 +266,7 @@ function readArgvConfigSync() {
// Fallback to default
if (!argvConfig) {
argvConfig = {
'disable-color-correct-rendering': true // Force pre-Chrome-60 color profile handling (for https://github.com/Microsoft/vscode/issues/51791)
'disable-color-correct-rendering': true // Force pre-Chrome-60 color profile handling (for https://github.com/microsoft/vscode/issues/51791)
};
}
@@ -300,7 +300,7 @@ function createDefaultArgvConfigSync(argvConfigPath) {
' // "disable-hardware-acceleration": true,',
'',
' // Enabled by default by VS Code to resolve color issues in the renderer',
' // See https://github.com/Microsoft/vscode/issues/51791 for details',
' // See https://github.com/microsoft/vscode/issues/51791 for details',
' "disable-color-correct-rendering": true',
'}'
];
@@ -506,46 +506,28 @@ function registerListeners() {
}
/**
* @returns {{ ensureExists: () => Promise<string | undefined> }}
* @returns {string | undefined} the location to use for the code cache
* or `undefined` if disabled.
*/
function getNodeCachedDir() {
return new class {
function getCodeCachePath() {
constructor() {
this.value = this.compute();
}
// explicitly disabled via CLI args
if (process.argv.indexOf('--no-cached-data') > 0) {
return undefined;
}
async ensureExists() {
if (typeof this.value === 'string') {
try {
await mkdirp(this.value);
// running out of sources
if (process.env['VSCODE_DEV']) {
return undefined;
}
return this.value;
} catch (error) {
// ignore
}
}
}
// require commit id
const commit = product.commit;
if (!commit) {
return undefined;
}
compute() {
if (process.argv.indexOf('--no-cached-data') > 0) {
return undefined;
}
// IEnvironmentService.isBuilt
if (process.env['VSCODE_DEV']) {
return undefined;
}
// find commit id
const commit = product.commit;
if (!commit) {
return undefined;
}
return path.join(userDataPath, 'CachedData', commit);
}
};
return path.join(userDataPath, 'CachedData', commit);
}
/**
@@ -560,6 +542,24 @@ function mkdirp(dir) {
});
}
/**
* @param {string | undefined} dir
* @returns {Promise<string | undefined>}
*/
async function mkdirpIgnoreError(dir) {
if (typeof dir === 'string') {
try {
await mkdirp(dir);
return dir;
} catch (error) {
// ignore
}
}
return undefined;
}
//#region NLS Support
/**