未验证 提交 a09826fc 编写于 作者: M Miguel Solorio 提交者: GitHub

Merge branch 'master' into fix-79618

......@@ -358,6 +358,10 @@
"diffEditor.removedTextBackground": "#892F4688",
// "diffEditor.removedTextBorder": "",
// Editor: Minimap
"minimap.selectionHighlight": "#750000",
// Workbench: Title
"titleBar.activeBackground": "#10192c",
// "titleBar.activeForeground": "",
......@@ -439,4 +443,4 @@
"terminal.ansiBrightCyan": "#78ffff",
"terminal.ansiBrightWhite": "#ffffff"
}
}
\ No newline at end of file
}
......@@ -17,6 +17,7 @@
"inputOption.activeBorder": "#a57a4c",
"selection.background": "#84613daa",
"editor.selectionBackground": "#84613daa",
"minimap.selectionHighlight": "#84613daa",
"editorWidget.background": "#131510",
"editorHoverWidget.background": "#221a14",
"editorGroupHeader.tabsBackground": "#131510",
......@@ -398,4 +399,4 @@
}
}
]
}
\ No newline at end of file
}
......@@ -11,6 +11,7 @@
"editor.background": "#1e1e1e",
"editor.foreground": "#c5c8c6",
"editor.selectionBackground": "#676b7180",
"minimap.selectionHighlight": "#676b7180",
"editor.selectionHighlightBackground": "#575b6180",
"editor.lineHighlightBackground": "#303030",
"editorLineNumber.activeForeground": "#949494",
......@@ -588,4 +589,4 @@
}
}
]
}
\ No newline at end of file
}
......@@ -23,6 +23,7 @@
"selection.background": "#ccccc7",
"editor.selectionHighlightBackground": "#575b6180",
"editor.selectionBackground": "#878b9180",
"minimap.selectionHighlight": "#878b9180",
"editor.wordHighlightBackground": "#4a4a7680",
"editor.wordHighlightStrongBackground": "#6a6a9680",
"editor.lineHighlightBackground": "#3e3d32",
......
......@@ -499,6 +499,7 @@
"editor.lineHighlightBackground": "#E4F6D4",
"editorLineNumber.activeForeground": "#9769dc",
"editor.selectionBackground": "#C9D0D9",
"minimap.selectionHighlight": "#C9D0D9",
"tab.modifiedBorder": "#f1897f",
"panel.background": "#F5F5F5",
"sideBar.background": "#F2F2F2",
......
......@@ -21,6 +21,7 @@
"editor.foreground": "#F8F8F8",
"editorWhitespace.foreground": "#c10000",
"editor.selectionBackground": "#750000",
"minimap.selectionHighlight": "#750000",
"editorLineNumber.foreground": "#ff777788",
"editorLineNumber.activeForeground": "#ffbbbb88",
"editorWidget.background": "#300000",
......@@ -411,4 +412,4 @@
}
}
]
}
\ No newline at end of file
}
......@@ -359,6 +359,7 @@
"editor.lineHighlightBackground": "#073642",
"editorLineNumber.activeForeground": "#949494",
"editor.selectionBackground": "#274642",
"minimap.selectionHighlight": "#274642",
"editorIndentGuide.background": "#93A1A180",
"editorIndentGuide.activeBackground": "#C3E1E180",
"editorHoverWidget.background": "#004052",
......
......@@ -350,6 +350,7 @@
"editorWhitespace.foreground": "#586E7580",
"editor.lineHighlightBackground": "#EEE8D5",
"editor.selectionBackground": "#EEE8D5",
"minimap.selectionHighlight": "#EEE8D5",
"editorIndentGuide.background": "#586E7580",
"editorIndentGuide.activeBackground": "#081E2580",
"editorHoverWidget.background": "#CCC4B0",
......@@ -486,4 +487,4 @@
// Interactive Playground
"walkThrough.embeddedEditorBackground": "#00000014"
}
}
\ No newline at end of file
}
......@@ -14,6 +14,7 @@
"editor.background": "#002451",
"editor.foreground": "#ffffff",
"editor.selectionBackground": "#003f8e",
"minimap.selectionHighlight": "#003f8e",
"editor.lineHighlightBackground": "#00346e",
"editorLineNumber.activeForeground": "#949494",
"editorCursor.foreground": "#ffffff",
......@@ -255,4 +256,4 @@
}
}
]
}
\ No newline at end of file
}
......@@ -245,7 +245,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
this.logger.error(message, data);
}
private logTelemetry(eventName: string, properties?: { [prop: string]: string }) {
private logTelemetry(eventName: string, properties?: { readonly [prop: string]: string }) {
this.telemetryReporter.logTelemetry(eventName, properties);
}
......@@ -287,7 +287,6 @@ export default class TypeScriptServiceClient extends Disposable implements IType
const apiVersion = this.versionPicker.currentVersion.apiVersion || API.defaultVersion;
this.onDidChangeTypeScriptVersion(currentVersion);
let mytoken = ++this.token;
const handle = this.typescriptServerSpawner.spawn(currentVersion, this.configuration, this.pluginManager);
this.serverState = new ServerState.Running(handle, apiVersion, undefined, true);
......@@ -297,10 +296,13 @@ export default class TypeScriptServiceClient extends Disposable implements IType
"tsserver.spawned" : {
"${include}": [
"${TypeScriptCommonProperties}"
]
],
"localTypeScriptVersion": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
this.logTelemetry('tsserver.spawned');
this.logTelemetry('tsserver.spawned', {
localTypeScriptVersion: this.versionProvider.localVersion ? this.versionProvider.localVersion.versionString : '',
});
handle.onError((err: Error) => {
if (this.token !== mytoken) {
......
......@@ -14,7 +14,7 @@ interface PackageInfo {
}
export default interface TelemetryReporter {
logTelemetry(eventName: string, properties?: { [prop: string]: string }): void;
logTelemetry(eventName: string, properties?: { readonly [prop: string]: string }): void;
dispose(): void;
}
......
{
"name": "code-oss-dev",
"version": "1.39.0",
"distro": "bdaae34df8cacb0a6c48750e611bc4cd122f8df4",
"distro": "bea7d39067de4f7dcb65ac20c1a76000304ad939",
"author": {
"name": "Microsoft Corporation"
},
......
......@@ -16,7 +16,7 @@
media-src 'none';
script-src 'self' https://az416426.vo.msecnd.net 'unsafe-eval' https: 'sha256-4DqvCTjCHj2KW4QxC/Yt6uBwMRyYiEg7kOoykSEkonQ=' 'sha256-meDZW3XhN5JmdjFUrWGhTouRKBiWYtXHltaKnqn/WMo=';
child-src 'self';
frame-src 'self' {{WEBVIEW_ENDPOINT}} https://*.vscode-webview-test.com;
frame-src 'self' https://*.vscode-webview-test.com;
worker-src 'self';
style-src 'self' 'unsafe-inline';
connect-src 'self' ws: wss: https:;
......
......@@ -16,7 +16,7 @@
media-src 'none';
script-src 'self' https://az416426.vo.msecnd.net 'unsafe-eval' https: 'sha256-4DqvCTjCHj2KW4QxC/Yt6uBwMRyYiEg7kOoykSEkonQ=';
child-src 'self';
frame-src 'self' {{WEBVIEW_ENDPOINT}} https://*.vscode-webview-test.com;
frame-src 'self' https://*.vscode-webview-test.com;
worker-src 'self';
style-src 'self' 'unsafe-inline';
connect-src 'self' ws: wss: https:;
......
......@@ -182,7 +182,7 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
this._variableResolver,
isWorkspaceShellAllowed,
pkg.version,
terminalConfig.get<boolean>('setLocaleVariables', false),
terminalConfig.get<'auto' | 'off' | 'on'>('detectLocale', 'auto'),
baseEnv
);
......
......@@ -11,10 +11,11 @@ import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IListService } from 'vs/platform/list/browser/listService';
import { IEditorCommandsContext } from 'vs/workbench/common/editor';
import { ResourceContextKey } from 'vs/workbench/common/resources';
import { ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor';
import { getMultiSelectedResources } from 'vs/workbench/contrib/files/browser/files';
import { WebviewPanelResourceScheme } from 'vs/workbench/contrib/webview/browser/webviewEditorInput';
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
const viewCategory = nls.localize('viewCategory', "View");
......@@ -60,12 +61,18 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
id: REOPEN_WITH_COMMAND_ID,
weight: KeybindingWeight.WorkbenchContrib,
when: undefined,
handler: async (accessor: ServicesAccessor, resource: URI | undefined) => {
handler: async (accessor: ServicesAccessor, resource?: URI, editorContext?: IEditorCommandsContext) => {
const customEditorService = accessor.get(ICustomEditorService);
const editorService = accessor.get(IEditorService);
if (!resource) {
const editorGroupService = accessor.get(IEditorGroupsService);
let group: IEditorGroup | undefined;
if (editorContext) {
group = editorGroupService.getGroup(editorContext.groupId);
} else if (!resource) {
if (editorService.activeEditor) {
resource = editorService.activeEditor.getResource();
group = editorGroupService.activeGroup;
}
}
......@@ -73,15 +80,11 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
return;
}
if (resource.scheme === WebviewPanelResourceScheme) {
resource = URI.parse(decodeURIComponent(resource.query));
}
// Make sure the context menu has been dismissed before we prompt.
// Otherwise with webviews, we will sometimes close the prompt instantly when the webview is
// refocused by the workbench
setTimeout(() => {
customEditorService.promptOpenWith(resource!, undefined, undefined);
customEditorService.promptOpenWith(resource!, undefined, group);
}, 10);
}
});
......
......@@ -12,11 +12,11 @@ import { URI } from 'vs/base/common/uri';
import { generateUuid } from 'vs/base/common/uuid';
import * as nls from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { IEditorOptions, ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IEditor, IEditorInput } from 'vs/workbench/common/editor';
import { EditorOptions, IEditor, IEditorInput } from 'vs/workbench/common/editor';
import { webviewEditorsExtensionPoint } from 'vs/workbench/contrib/customEditor/browser/extensionPoint';
import { CustomEditorDiscretion, CustomEditorInfo, CustomEditorSelector, ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor';
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
......@@ -93,7 +93,7 @@ export class CustomEditorService implements ICustomEditorService {
if (pick.id === defaultEditorId) {
const fileInput = this.instantiationService.createInstance(FileEditorInput, resource, undefined, undefined);
return this.editorService.openEditor(fileInput, { ...options, ignoreOverrides: true }, group);
return this.openEditorForResource(resource, fileInput, { ...options, ignoreOverrides: true }, group);
} else {
return this.openWith(resource, pick.id!, options, group);
}
......@@ -115,6 +115,25 @@ export class CustomEditorService implements ICustomEditorService {
if (group) {
input.updateGroup(group!.id);
}
return this.openEditorForResource(resource, input, options, group);
}
private async openEditorForResource(
resource: URI,
input: IEditorInput,
options?: IEditorOptions,
group?: IEditorGroup
): Promise<IEditor | undefined> {
if (group) {
const existingEditors = group.editors.filter(editor => editor.getResource() && editor.getResource()!.toString() === resource.toString());
if (existingEditors.length) {
await this.editorService.replaceEditors([{
editor: existingEditors[0],
replacement: input,
options: options ? EditorOptions.create(options) : undefined,
}], group);
}
}
return this.editorService.openEditor(input, options, group);
}
}
......
......@@ -194,10 +194,16 @@ configurationRegistry.registerConfiguration({
type: 'number',
default: 1000
},
'terminal.integrated.setLocaleVariables': {
markdownDescription: nls.localize('terminal.integrated.setLocaleVariables', "Controls whether locale variables are set at startup of the terminal."),
type: 'boolean',
default: true
'terminal.integrated.detectLocale': {
markdownDescription: nls.localize('terminal.integrated.detectLocale', "Controls whether to detect and set the `$LANG` environment variable to a UTF-8 compliant option since VS Code's terminal only supports UTF-8 encoded data coming from the shell."),
type: 'string',
enum: ['auto', 'off', 'on'],
enumDescriptions: [
nls.localize('terminal.integrated.detectLocale.auto', "Set the `$LANG` environment variable if the existing variable does not exist or it does not end in `'.UTF-8'`."),
nls.localize('terminal.integrated.detectLocale.off', "Do not set the `$LANG` environment variable."),
nls.localize('terminal.integrated.detectLocale.on', "Always set the `$LANG` environment variable.")
],
default: 'auto'
},
'terminal.integrated.rendererType': {
type: 'string',
......
......@@ -227,7 +227,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
const isWorkspaceShellAllowed = this._configHelper.checkWorkspaceShellPermissions();
this._configHelper.showRecommendations(shellLaunchConfig);
const baseEnv = this._configHelper.config.inheritEnv ? processEnv : await this._terminalInstanceService.getMainProcessParentEnv();
const env = terminalEnvironment.createTerminalEnvironment(shellLaunchConfig, lastActiveWorkspace, envFromConfigValue, this._configurationResolverService, isWorkspaceShellAllowed, this._productService.version, this._configHelper.config.setLocaleVariables, baseEnv);
const env = terminalEnvironment.createTerminalEnvironment(shellLaunchConfig, lastActiveWorkspace, envFromConfigValue, this._configurationResolverService, isWorkspaceShellAllowed, this._productService.version, this._configHelper.config.detectLocale, baseEnv);
const useConpty = this._configHelper.config.windowsEnableConpty && !isScreenReaderModeEnabled;
return this._terminalInstanceService.createTerminalProcess(shellLaunchConfig, initialCwd, cols, rows, env, useConpty);
......
......@@ -100,7 +100,7 @@ export interface ITerminalConfiguration {
fontSize: number;
letterSpacing: number;
lineHeight: number;
setLocaleVariables: boolean;
detectLocale: 'auto' | 'off' | 'on';
scrollback: number;
commandsToSkipShell: string[];
cwd: string;
......
......@@ -51,13 +51,13 @@ function _mergeEnvironmentValue(env: ITerminalEnvironment, key: string, value: s
}
}
export function addTerminalEnvironmentKeys(env: platform.IProcessEnvironment, version: string | undefined, locale: string | undefined, setLocaleVariables: boolean): void {
export function addTerminalEnvironmentKeys(env: platform.IProcessEnvironment, version: string | undefined, locale: string | undefined, detectLocale: 'auto' | 'off' | 'on'): void {
env['TERM_PROGRAM'] = 'vscode';
if (version) {
env['TERM_PROGRAM_VERSION'] = version;
}
if (setLocaleVariables) {
env['LANG'] = _getLangEnvVariable(locale);
if (shouldSetLangEnvVariable(env, detectLocale)) {
env['LANG'] = getLangEnvVariable(locale);
}
env['COLORTERM'] = 'truecolor';
}
......@@ -88,37 +88,87 @@ function resolveConfigurationVariables(configurationResolverService: IConfigurat
return env;
}
function _getLangEnvVariable(locale?: string) {
export function shouldSetLangEnvVariable(env: platform.IProcessEnvironment, detectLocale: 'auto' | 'off' | 'on'): boolean {
if (detectLocale === 'on') {
return true;
}
if (detectLocale === 'auto') {
return !env['LANG'] || env['LANG'].search(/\.UTF\-8$/) === -1;
}
return false; // 'off'
}
export function getLangEnvVariable(locale?: string): string {
const parts = locale ? locale.split('-') : [];
const n = parts.length;
if (n === 0) {
// Fallback to en_US to prevent possible encoding issues.
// Fallback to en_US if the locale is unknown
return 'en_US.UTF-8';
}
if (n === 1) {
// app.getLocale can return just a language without a variant, fill in the variant for
// supported languages as many shells expect a 2-part locale.
// The local may only contain the language, not the variant, if this is the case guess the
// variant such that it can be used as a valid $LANG variable. The language variant chosen
// is the original and/or most prominent with help from
// https://stackoverflow.com/a/2502675/1156119
// The list of locales was generated by running `locale -a` on macOS
const languageVariants: { [key: string]: string } = {
af: 'ZA',
am: 'ET',
be: 'BY',
bg: 'BG',
ca: 'ES',
cs: 'CZ',
da: 'DK',
// de: 'AT',
// de: 'CH',
de: 'DE',
el: 'GR',
// en: 'AU',
// en: 'CA',
// en: 'GB',
// en: 'IE',
// en: 'NZ',
en: 'US',
es: 'ES',
et: 'EE',
eu: 'ES',
fi: 'FI',
// fr: 'BE',
// fr: 'CA',
// fr: 'CH',
fr: 'FR',
he: 'IL',
hr: 'HR',
hu: 'HU',
hy: 'AM',
is: 'IS',
// it: 'CH',
it: 'IT',
ja: 'JP',
kk: 'KZ',
ko: 'KR',
lt: 'LT',
// nl: 'BE',
nl: 'NL',
no: 'NO',
pl: 'PL',
pt: 'BR',
// pt: 'PT',
ro: 'RO',
ru: 'RU',
sk: 'SK',
zh: 'CN'
sl: 'SI',
sr: 'YU',
sv: 'SE',
tr: 'TR',
uk: 'UA',
zh: 'CN',
};
if (parts[0] in languageVariants) {
parts.push(languageVariants[parts[0]]);
}
} else {
// Ensure the variant is uppercase
// Ensure the variant is uppercase to be a valid $LANG
parts[1] = parts[1].toUpperCase();
}
return parts.join('_') + '.UTF-8';
......@@ -294,7 +344,7 @@ export function createTerminalEnvironment(
configurationResolverService: IConfigurationResolverService | undefined,
isWorkspaceShellAllowed: boolean,
version: string | undefined,
setLocaleVariables: boolean,
detectLocale: 'auto' | 'off' | 'on',
baseEnv: platform.IProcessEnvironment
): platform.IProcessEnvironment {
// Create a terminal environment based on settings, launch config and permissions
......@@ -329,7 +379,7 @@ export function createTerminalEnvironment(
mergeEnvironments(env, shellLaunchConfig.env);
// Adding other env keys necessary to create the process
addTerminalEnvironmentKeys(env, version, platform.locale, setLocaleVariables);
addTerminalEnvironmentKeys(env, version, platform.locale, detectLocale);
}
return env;
}
......@@ -5,30 +5,110 @@
import * as assert from 'assert';
import * as platform from 'vs/base/common/platform';
import * as terminalEnvironment from 'vs/workbench/contrib/terminal/common/terminalEnvironment';
import { URI as Uri } from 'vs/base/common/uri';
import { IStringDictionary } from 'vs/base/common/collections';
import { addTerminalEnvironmentKeys, mergeEnvironments, getCwd, getDefaultShell, getLangEnvVariable, shouldSetLangEnvVariable } from 'vs/workbench/contrib/terminal/common/terminalEnvironment';
suite('Workbench - TerminalEnvironment', () => {
test('addTerminalEnvironmentKeys', () => {
const env: { [key: string]: any } = { FOO: 'bar' };
const locale = 'en-au';
terminalEnvironment.addTerminalEnvironmentKeys(env, '1.2.3', locale, true);
assert.equal(env['TERM_PROGRAM'], 'vscode');
assert.equal(env['TERM_PROGRAM_VERSION'], '1.2.3');
assert.equal(env['LANG'], 'en_AU.UTF-8', 'LANG is equal to the requested locale with UTF-8');
const env2: { [key: string]: any } = { FOO: 'bar' };
terminalEnvironment.addTerminalEnvironmentKeys(env2, '1.2.3', undefined, true);
assert.equal(env2['LANG'], 'en_US.UTF-8', 'LANG is equal to en_US.UTF-8 as fallback.'); // More info on issue #14586
const env3 = { LANG: 'replace' };
terminalEnvironment.addTerminalEnvironmentKeys(env3, '1.2.3', undefined, true);
assert.equal(env3['LANG'], 'en_US.UTF-8', 'LANG is set to the fallback LANG');
const env4 = { LANG: 'en_US.UTF-8' };
terminalEnvironment.addTerminalEnvironmentKeys(env3, '1.2.3', undefined, true);
assert.equal(env4['LANG'], 'en_US.UTF-8', 'LANG is equal to the parent environment\'s LANG');
suite('addTerminalEnvironmentKeys', () => {
test('should set expected variables', () => {
const env: { [key: string]: any } = {};
addTerminalEnvironmentKeys(env, '1.2.3', 'en', 'on');
assert.equal(env['TERM_PROGRAM'], 'vscode');
assert.equal(env['TERM_PROGRAM_VERSION'], '1.2.3');
assert.equal(env['COLORTERM'], 'truecolor');
assert.equal(env['LANG'], 'en_US.UTF-8');
});
test('should use language variant for LANG that is provided in locale', () => {
const env: { [key: string]: any } = {};
addTerminalEnvironmentKeys(env, '1.2.3', 'en-au', 'on');
assert.equal(env['LANG'], 'en_AU.UTF-8', 'LANG is equal to the requested locale with UTF-8');
});
test('should fallback to en_US when no locale is provided', () => {
const env2: { [key: string]: any } = { FOO: 'bar' };
addTerminalEnvironmentKeys(env2, '1.2.3', undefined, 'on');
assert.equal(env2['LANG'], 'en_US.UTF-8', 'LANG is equal to en_US.UTF-8 as fallback.'); // More info on issue #14586
});
test('should fallback to en_US when an invalid locale is provided', () => {
const env3 = { LANG: 'replace' };
addTerminalEnvironmentKeys(env3, '1.2.3', undefined, 'on');
assert.equal(env3['LANG'], 'en_US.UTF-8', 'LANG is set to the fallback LANG');
});
test('should override existing LANG', () => {
const env4 = { LANG: 'en_AU.UTF-8' };
addTerminalEnvironmentKeys(env4, '1.2.3', undefined, 'on');
assert.equal(env4['LANG'], 'en_US.UTF-8', 'LANG is equal to the parent environment\'s LANG');
});
});
suite('shouldSetLangEnvVariable', () => {
test('auto', () => {
assert.equal(shouldSetLangEnvVariable({}, 'auto'), true);
assert.equal(shouldSetLangEnvVariable({ LANG: 'en-US' }, 'auto'), true);
assert.equal(shouldSetLangEnvVariable({ LANG: 'en-US.UTF-8' }, 'auto'), false);
});
test('off', () => {
assert.equal(shouldSetLangEnvVariable({}, 'off'), false);
assert.equal(shouldSetLangEnvVariable({ LANG: 'en-US' }, 'off'), false);
assert.equal(shouldSetLangEnvVariable({ LANG: 'en-US.UTF-8' }, 'off'), false);
});
test('on', () => {
assert.equal(shouldSetLangEnvVariable({}, 'on'), true);
assert.equal(shouldSetLangEnvVariable({ LANG: 'en-US' }, 'on'), true);
assert.equal(shouldSetLangEnvVariable({ LANG: 'en-US.UTF-8' }, 'on'), true);
});
});
suite('getLangEnvVariable', () => {
test('should fallback to en_US when no locale is provided', () => {
assert.equal(getLangEnvVariable(undefined), 'en_US.UTF-8');
assert.equal(getLangEnvVariable(''), 'en_US.UTF-8');
});
test('should fallback to default language variants when variant isn\'t provided', () => {
assert.equal(getLangEnvVariable('af'), 'af_ZA.UTF-8');
assert.equal(getLangEnvVariable('am'), 'am_ET.UTF-8');
assert.equal(getLangEnvVariable('be'), 'be_BY.UTF-8');
assert.equal(getLangEnvVariable('bg'), 'bg_BG.UTF-8');
assert.equal(getLangEnvVariable('ca'), 'ca_ES.UTF-8');
assert.equal(getLangEnvVariable('cs'), 'cs_CZ.UTF-8');
assert.equal(getLangEnvVariable('da'), 'da_DK.UTF-8');
assert.equal(getLangEnvVariable('de'), 'de_DE.UTF-8');
assert.equal(getLangEnvVariable('el'), 'el_GR.UTF-8');
assert.equal(getLangEnvVariable('en'), 'en_US.UTF-8');
assert.equal(getLangEnvVariable('es'), 'es_ES.UTF-8');
assert.equal(getLangEnvVariable('et'), 'et_EE.UTF-8');
assert.equal(getLangEnvVariable('eu'), 'eu_ES.UTF-8');
assert.equal(getLangEnvVariable('fi'), 'fi_FI.UTF-8');
assert.equal(getLangEnvVariable('fr'), 'fr_FR.UTF-8');
assert.equal(getLangEnvVariable('he'), 'he_IL.UTF-8');
assert.equal(getLangEnvVariable('hr'), 'hr_HR.UTF-8');
assert.equal(getLangEnvVariable('hu'), 'hu_HU.UTF-8');
assert.equal(getLangEnvVariable('hy'), 'hy_AM.UTF-8');
assert.equal(getLangEnvVariable('is'), 'is_IS.UTF-8');
assert.equal(getLangEnvVariable('it'), 'it_IT.UTF-8');
assert.equal(getLangEnvVariable('ja'), 'ja_JP.UTF-8');
assert.equal(getLangEnvVariable('kk'), 'kk_KZ.UTF-8');
assert.equal(getLangEnvVariable('ko'), 'ko_KR.UTF-8');
assert.equal(getLangEnvVariable('lt'), 'lt_LT.UTF-8');
assert.equal(getLangEnvVariable('nl'), 'nl_NL.UTF-8');
assert.equal(getLangEnvVariable('no'), 'no_NO.UTF-8');
assert.equal(getLangEnvVariable('pl'), 'pl_PL.UTF-8');
assert.equal(getLangEnvVariable('pt'), 'pt_BR.UTF-8');
assert.equal(getLangEnvVariable('ro'), 'ro_RO.UTF-8');
assert.equal(getLangEnvVariable('ru'), 'ru_RU.UTF-8');
assert.equal(getLangEnvVariable('sk'), 'sk_SK.UTF-8');
assert.equal(getLangEnvVariable('sl'), 'sl_SI.UTF-8');
assert.equal(getLangEnvVariable('sr'), 'sr_YU.UTF-8');
assert.equal(getLangEnvVariable('sv'), 'sv_SE.UTF-8');
assert.equal(getLangEnvVariable('tr'), 'tr_TR.UTF-8');
assert.equal(getLangEnvVariable('uk'), 'uk_UA.UTF-8');
assert.equal(getLangEnvVariable('zh'), 'zh_CN.UTF-8');
});
test('should set language variant based on full locale', () => {
assert.equal(getLangEnvVariable('en-AU'), 'en_AU.UTF-8');
assert.equal(getLangEnvVariable('en-au'), 'en_AU.UTF-8');
assert.equal(getLangEnvVariable('fa-ke'), 'fa_KE.UTF-8');
});
});
suite('mergeEnvironments', () => {
......@@ -39,7 +119,7 @@ suite('Workbench - TerminalEnvironment', () => {
const other = {
c: 'd'
};
terminalEnvironment.mergeEnvironments(parent, other);
mergeEnvironments(parent, other);
assert.deepEqual(parent, {
a: 'b',
c: 'd'
......@@ -56,7 +136,7 @@ suite('Workbench - TerminalEnvironment', () => {
const other = {
A: 'c'
};
terminalEnvironment.mergeEnvironments(parent, other);
mergeEnvironments(parent, other);
assert.deepEqual(parent, {
a: 'c'
});
......@@ -70,7 +150,7 @@ suite('Workbench - TerminalEnvironment', () => {
const other: IStringDictionary<string | null> = {
a: null
};
terminalEnvironment.mergeEnvironments(parent, other);
mergeEnvironments(parent, other);
assert.deepEqual(parent, {
c: 'd'
});
......@@ -87,7 +167,7 @@ suite('Workbench - TerminalEnvironment', () => {
const other: IStringDictionary<string | null> = {
A: null
};
terminalEnvironment.mergeEnvironments(parent, other);
mergeEnvironments(parent, other);
assert.deepEqual(parent, {
c: 'd'
});
......@@ -101,37 +181,37 @@ suite('Workbench - TerminalEnvironment', () => {
}
test('should default to userHome for an empty workspace', () => {
assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, undefined, undefined), '/userHome/');
assertPathsMatch(getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, undefined, undefined), '/userHome/');
});
test('should use to the workspace if it exists', () => {
assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, Uri.file('/foo'), undefined), '/foo');
assertPathsMatch(getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, Uri.file('/foo'), undefined), '/foo');
});
test('should use an absolute custom cwd as is', () => {
assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, undefined, '/foo'), '/foo');
assertPathsMatch(getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, undefined, '/foo'), '/foo');
});
test('should normalize a relative custom cwd against the workspace path', () => {
assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, Uri.file('/bar'), 'foo'), '/bar/foo');
assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, Uri.file('/bar'), './foo'), '/bar/foo');
assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, Uri.file('/bar'), '../foo'), '/foo');
assertPathsMatch(getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, Uri.file('/bar'), 'foo'), '/bar/foo');
assertPathsMatch(getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, Uri.file('/bar'), './foo'), '/bar/foo');
assertPathsMatch(getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, Uri.file('/bar'), '../foo'), '/foo');
});
test('should fall back for relative a custom cwd that doesn\'t have a workspace', () => {
assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, undefined, 'foo'), '/userHome/');
assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, undefined, './foo'), '/userHome/');
assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, undefined, '../foo'), '/userHome/');
assertPathsMatch(getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, undefined, 'foo'), '/userHome/');
assertPathsMatch(getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, undefined, './foo'), '/userHome/');
assertPathsMatch(getCwd({ executable: undefined, args: [] }, '/userHome/', undefined, undefined, undefined, '../foo'), '/userHome/');
});
test('should ignore custom cwd when told to ignore', () => {
assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [], ignoreConfigurationCwd: true }, '/userHome/', undefined, undefined, Uri.file('/bar'), '/foo'), '/bar');
assertPathsMatch(getCwd({ executable: undefined, args: [], ignoreConfigurationCwd: true }, '/userHome/', undefined, undefined, Uri.file('/bar'), '/foo'), '/bar');
});
});
suite('getDefaultShell', () => {
test('should change Sysnative to System32 in non-WoW64 systems', () => {
const shell = terminalEnvironment.getDefaultShell(key => {
const shell = getDefaultShell(key => {
return ({
'terminal.integrated.shell.windows': { user: 'C:\\Windows\\Sysnative\\cmd.exe', value: undefined, default: undefined }
} as any)[key];
......@@ -140,7 +220,7 @@ suite('Workbench - TerminalEnvironment', () => {
});
test('should not change Sysnative to System32 in WoW64 systems', () => {
const shell = terminalEnvironment.getDefaultShell(key => {
const shell = getDefaultShell(key => {
return ({
'terminal.integrated.shell.windows': { user: 'C:\\Windows\\Sysnative\\cmd.exe', value: undefined, default: undefined }
} as any)[key];
......@@ -149,21 +229,21 @@ suite('Workbench - TerminalEnvironment', () => {
});
test('should use automationShell when specified', () => {
const shell1 = terminalEnvironment.getDefaultShell(key => {
const shell1 = getDefaultShell(key => {
return ({
'terminal.integrated.shell.windows': { user: 'shell', value: undefined, default: undefined },
'terminal.integrated.automationShell.windows': { user: undefined, value: undefined, default: undefined }
} as any)[key];
}, false, 'DEFAULT', false, 'C:\\Windows', undefined, undefined, {} as any, false, platform.Platform.Windows);
assert.equal(shell1, 'shell', 'automationShell was false');
const shell2 = terminalEnvironment.getDefaultShell(key => {
const shell2 = getDefaultShell(key => {
return ({
'terminal.integrated.shell.windows': { user: 'shell', value: undefined, default: undefined },
'terminal.integrated.automationShell.windows': { user: undefined, value: undefined, default: undefined }
} as any)[key];
}, false, 'DEFAULT', false, 'C:\\Windows', undefined, undefined, {} as any, true, platform.Platform.Windows);
assert.equal(shell2, 'shell', 'automationShell was true');
const shell3 = terminalEnvironment.getDefaultShell(key => {
const shell3 = getDefaultShell(key => {
return ({
'terminal.integrated.shell.windows': { user: 'shell', value: undefined, default: undefined },
'terminal.integrated.automationShell.windows': { user: 'automationShell', value: undefined, default: undefined }
......
......@@ -11,7 +11,7 @@ import { EditorInput, EditorModel, GroupIdentifier, IEditorInput, Verbosity } fr
import { WebviewEditorOverlay } from 'vs/workbench/contrib/webview/browser/webview';
import { UnownedDisposable as Unowned } from 'vs/base/common/lifecycle';
export const WebviewPanelResourceScheme = 'webview-panel';
const WebviewPanelResourceScheme = 'webview-panel';
class WebviewIconsManager {
private readonly _icons = new Map<string, { light: URI, dark: URI }>();
......
......@@ -19,6 +19,7 @@ import { WebviewPortMappingManager } from 'vs/workbench/contrib/webview/common/p
import { loadLocalResource } from 'vs/workbench/contrib/webview/common/resourceLoader';
import { getWebviewThemeData } from 'vs/workbench/contrib/webview/common/themeing';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { isWeb } from 'vs/base/common/platform';
interface WebviewContent {
readonly html: string;
......@@ -47,9 +48,7 @@ export class IFrameWebview extends Disposable implements Webview {
@IConfigurationService private readonly _configurationService: IConfigurationService,
) {
super();
const useExternalEndpoint = this._configurationService.getValue<string>('webview.experimental.useExternalEndpoint');
if (!useExternalEndpoint && (!environmentService.options || typeof environmentService.options.webviewEndpoint !== 'string')) {
if (!this.useExternalEndpoint && (!environmentService.options || typeof environmentService.options.webviewEndpoint !== 'string')) {
throw new Error('To use iframe based webviews, you must configure `environmentService.webviewEndpoint`');
}
......@@ -155,7 +154,7 @@ export class IFrameWebview extends Disposable implements Webview {
}
private get externalEndpoint(): string | undefined {
const useExternalEndpoint = this._configurationService.getValue<boolean>('webview.experimental.useExternalEndpoint');
const useExternalEndpoint = this.useExternalEndpoint;
if (!useExternalEndpoint) {
return undefined;
}
......@@ -163,6 +162,10 @@ export class IFrameWebview extends Disposable implements Webview {
return `https://{{uuid}}.vscode-webview-test.com/${commit}`;
}
private get useExternalEndpoint(): boolean {
return isWeb || this._configurationService.getValue<boolean>('webview.experimental.useExternalEndpoint');
}
public mountTo(parent: HTMLElement) {
if (this.element) {
parent.appendChild(this.element);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册