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

@@ -21,7 +21,6 @@ STATIC_VALUES.set('isEdge', _userAgent.indexOf('Edg/') >= 0);
STATIC_VALUES.set('isFirefox', _userAgent.indexOf('Firefox') >= 0);
STATIC_VALUES.set('isChrome', _userAgent.indexOf('Chrome') >= 0);
STATIC_VALUES.set('isSafari', _userAgent.indexOf('Safari') >= 0);
STATIC_VALUES.set('isIPad', _userAgent.indexOf('iPad') >= 0);
const hasOwnProperty = Object.prototype.hasOwnProperty;

View File

@@ -5,7 +5,7 @@
import { localize } from 'vs/nls';
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { isMacintosh, isLinux, isWindows, isWeb } from 'vs/base/common/platform';
import { isMacintosh, isLinux, isWindows, isWeb, isIOS } from 'vs/base/common/platform';
export const IsMacContext = new RawContextKey<boolean>('isMac', isMacintosh, localize('isMac', "Whether the operating system is macOS"));
export const IsLinuxContext = new RawContextKey<boolean>('isLinux', isLinux, localize('isLinux', "Whether the operating system is Linux"));
@@ -13,6 +13,7 @@ export const IsWindowsContext = new RawContextKey<boolean>('isWindows', isWindow
export const IsWebContext = new RawContextKey<boolean>('isWeb', isWeb, localize('isWeb', "Whether the platform is a web browser"));
export const IsMacNativeContext = new RawContextKey<boolean>('isMacNative', isMacintosh && !isWeb, localize('isMacNative', "Whether the operating system is macOS on a non-browser platform"));
export const IsIOSContext = new RawContextKey<boolean>('isIOS', isIOS, localize('isIOS', "Whether the operating system is IOS"));
export const IsDevelopmentContext = new RawContextKey<boolean>('isDevelopment', false, true);

View File

@@ -0,0 +1,53 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
import * as assert from 'assert';
suite('ContextKeyService', () => {
test('updateParent', () => {
const root = new ContextKeyService(new TestConfigurationService());
const parent1 = root.createScoped(document.createElement('div'));
const parent2 = root.createScoped(document.createElement('div'));
const child = parent1.createScoped(document.createElement('div'));
parent1.createKey('testA', 1);
parent1.createKey('testB', 2);
parent1.createKey('testD', 0);
parent2.createKey('testA', 3);
parent2.createKey('testC', 4);
parent2.createKey('testD', 0);
let complete: () => void;
let reject: (err: Error) => void;
const p = new Promise<void>((_complete, _reject) => {
complete = _complete;
reject = _reject;
});
child.onDidChangeContext(e => {
try {
assert.ok(e.affectsSome(new Set(['testA'])), 'testA changed');
assert.ok(e.affectsSome(new Set(['testB'])), 'testB changed');
assert.ok(e.affectsSome(new Set(['testC'])), 'testC changed');
assert.ok(!e.affectsSome(new Set(['testD'])), 'testD did not change');
assert.strictEqual(child.getContextKeyValue('testA'), 3);
assert.strictEqual(child.getContextKeyValue('testB'), undefined);
assert.strictEqual(child.getContextKeyValue('testC'), 4);
assert.strictEqual(child.getContextKeyValue('testD'), 0);
} catch (err) {
reject(err);
return;
}
complete();
});
child.updateParent(parent2);
return p;
});
});

View File

@@ -27,7 +27,7 @@ suite('ContextKeyExpr', () => {
ContextKeyExpr.notEquals('c1', 'cc1'),
ContextKeyExpr.notEquals('c2', 'cc2'),
ContextKeyExpr.not('d1'),
ContextKeyExpr.not('d2'),
ContextKeyExpr.not('d2')
)!;
let b = ContextKeyExpr.and(
ContextKeyExpr.equals('b2', 'bb2'),