mirror of
https://github.com/coder/code-server.git
synced 2026-05-27 06:37:27 +02:00
chore(vscode): update to 1.53.2
These conflicts will be resolved in the following commits. We do it this way so that PR review is possible.
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Emitter, Event, PauseableEmitter } from 'vs/base/common/event';
|
||||
import { Emitter, PauseableEmitter } from 'vs/base/common/event';
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, DisposableStore, MutableDisposable } from 'vs/base/common/lifecycle';
|
||||
import { TernarySearchTree } from 'vs/base/common/map';
|
||||
import { distinct } from 'vs/base/common/objects';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
@@ -244,12 +244,14 @@ class CompositeContextKeyChangeEvent implements IContextKeyChangeEvent {
|
||||
}
|
||||
|
||||
export abstract class AbstractContextKeyService implements IContextKeyService {
|
||||
public _serviceBrand: undefined;
|
||||
declare _serviceBrand: undefined;
|
||||
|
||||
protected _isDisposed: boolean;
|
||||
protected _onDidChangeContext = new PauseableEmitter<IContextKeyChangeEvent>({ merge: input => new CompositeContextKeyChangeEvent(input) });
|
||||
protected _myContextId: number;
|
||||
|
||||
protected _onDidChangeContext = new PauseableEmitter<IContextKeyChangeEvent>({ merge: input => new CompositeContextKeyChangeEvent(input) });
|
||||
readonly onDidChangeContext = this._onDidChangeContext.event;
|
||||
|
||||
constructor(myContextId: number) {
|
||||
this._isDisposed = false;
|
||||
this._myContextId = myContextId;
|
||||
@@ -268,9 +270,6 @@ export abstract class AbstractContextKeyService implements IContextKeyService {
|
||||
return new ContextKey(this, key, defaultValue);
|
||||
}
|
||||
|
||||
public get onDidChangeContext(): Event<IContextKeyChangeEvent> {
|
||||
return this._onDidChangeContext.event;
|
||||
}
|
||||
|
||||
bufferChangeEvents(callback: Function): void {
|
||||
this._onDidChangeContext.pause();
|
||||
@@ -371,6 +370,7 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._onDidChangeContext.dispose();
|
||||
this._isDisposed = true;
|
||||
this._toDispose.dispose();
|
||||
}
|
||||
@@ -407,34 +407,34 @@ class ScopedContextKeyService extends AbstractContextKeyService {
|
||||
private _parent: AbstractContextKeyService;
|
||||
private _domNode: IContextKeyServiceTarget | undefined;
|
||||
|
||||
private _parentChangeListener: IDisposable | undefined;
|
||||
private readonly _parentChangeListener = new MutableDisposable();
|
||||
|
||||
constructor(parent: AbstractContextKeyService, domNode?: IContextKeyServiceTarget) {
|
||||
super(parent.createChildContext());
|
||||
this._parent = parent;
|
||||
this.updateParentChangeListener();
|
||||
this._updateParentChangeListener();
|
||||
|
||||
if (domNode) {
|
||||
this._domNode = domNode;
|
||||
if (this._domNode.hasAttribute(KEYBINDING_CONTEXT_ATTR)) {
|
||||
console.error('Element already has context attribute');
|
||||
let extraInfo = '';
|
||||
if ((this._domNode as HTMLElement).classList) {
|
||||
extraInfo = Array.from((this._domNode as HTMLElement).classList.values()).join(', ');
|
||||
}
|
||||
|
||||
console.error(`Element already has context attribute${extraInfo ? ': ' + extraInfo : ''}`);
|
||||
}
|
||||
this._domNode.setAttribute(KEYBINDING_CONTEXT_ATTR, String(this._myContextId));
|
||||
}
|
||||
}
|
||||
|
||||
private updateParentChangeListener(): void {
|
||||
if (this._parentChangeListener) {
|
||||
this._parentChangeListener.dispose();
|
||||
}
|
||||
|
||||
this._parentChangeListener = this._parent.onDidChangeContext(e => {
|
||||
// Forward parent events to this listener. Parent will change.
|
||||
this._onDidChangeContext.fire(e);
|
||||
});
|
||||
private _updateParentChangeListener(): void {
|
||||
// Forward parent events to this listener. Parent will change.
|
||||
this._parentChangeListener.value = this._parent.onDidChangeContext(this._onDidChangeContext.fire, this._onDidChangeContext);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._onDidChangeContext.dispose();
|
||||
this._isDisposed = true;
|
||||
this._parent.disposeContext(this._myContextId);
|
||||
this._parentChangeListener?.dispose();
|
||||
@@ -444,10 +444,6 @@ class ScopedContextKeyService extends AbstractContextKeyService {
|
||||
}
|
||||
}
|
||||
|
||||
public get onDidChangeContext(): Event<IContextKeyChangeEvent> {
|
||||
return this._onDidChangeContext.event;
|
||||
}
|
||||
|
||||
public getContextValuesContainer(contextId: number): Context {
|
||||
if (this._isDisposed) {
|
||||
return NullContext.INSTANCE;
|
||||
@@ -473,7 +469,7 @@ class ScopedContextKeyService extends AbstractContextKeyService {
|
||||
const thisContainer = this._parent.getContextValuesContainer(this._myContextId);
|
||||
const oldAllValues = thisContainer.collectAllValues();
|
||||
this._parent = parentContextKeyService;
|
||||
this.updateParentChangeListener();
|
||||
this._updateParentChangeListener();
|
||||
const newParentContainer = this._parent.getContextValuesContainer(this._parent.contextId);
|
||||
thisContainer.updateParent(newParentContainer);
|
||||
|
||||
|
||||
@@ -1278,11 +1278,11 @@ export class RawContextKey<T> extends ContextKeyDefinedExpr {
|
||||
return ContextKeyExpr.not(this.key);
|
||||
}
|
||||
|
||||
public isEqualTo(value: string): ContextKeyExpression {
|
||||
public isEqualTo(value: any): ContextKeyExpression {
|
||||
return ContextKeyExpr.equals(this.key, value);
|
||||
}
|
||||
|
||||
public notEqualsTo(value: string): ContextKeyExpression {
|
||||
public notEqualsTo(value: any): ContextKeyExpression {
|
||||
return ContextKeyExpr.notEquals(this.key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@ suite('ContextKeyService', () => {
|
||||
assert.ok(e.affectsSome(new Set(['testC'])), 'testC changed');
|
||||
assert.ok(!e.affectsSome(new Set(['testD'])), 'testD did not change');
|
||||
|
||||
assert.equal(child.getContextKeyValue('testA'), 3);
|
||||
assert.equal(child.getContextKeyValue('testB'), undefined);
|
||||
assert.equal(child.getContextKeyValue('testC'), 4);
|
||||
assert.equal(child.getContextKeyValue('testD'), 0);
|
||||
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;
|
||||
|
||||
@@ -67,7 +67,7 @@ suite('ContextKeyExpr', () => {
|
||||
function testExpression(expr: string, expected: boolean): void {
|
||||
// console.log(expr + ' ' + expected);
|
||||
let rules = ContextKeyExpr.deserialize(expr);
|
||||
assert.equal(rules!.evaluate(context), expected, expr);
|
||||
assert.strictEqual(rules!.evaluate(context), expected, expr);
|
||||
}
|
||||
function testBatch(expr: string, value: any): void {
|
||||
/* eslint-disable eqeqeq */
|
||||
@@ -153,17 +153,17 @@ suite('ContextKeyExpr', () => {
|
||||
|
||||
test('ContextKeyInExpr', () => {
|
||||
const ainb = ContextKeyExpr.deserialize('a in b')!;
|
||||
assert.equal(ainb.evaluate(createContext({ 'a': 3, 'b': [3, 2, 1] })), true);
|
||||
assert.equal(ainb.evaluate(createContext({ 'a': 3, 'b': [1, 2, 3] })), true);
|
||||
assert.equal(ainb.evaluate(createContext({ 'a': 3, 'b': [1, 2] })), false);
|
||||
assert.equal(ainb.evaluate(createContext({ 'a': 3 })), false);
|
||||
assert.equal(ainb.evaluate(createContext({ 'a': 3, 'b': null })), false);
|
||||
assert.equal(ainb.evaluate(createContext({ 'a': 'x', 'b': ['x'] })), true);
|
||||
assert.equal(ainb.evaluate(createContext({ 'a': 'x', 'b': ['y'] })), false);
|
||||
assert.equal(ainb.evaluate(createContext({ 'a': 'x', 'b': {} })), false);
|
||||
assert.equal(ainb.evaluate(createContext({ 'a': 'x', 'b': { 'x': false } })), true);
|
||||
assert.equal(ainb.evaluate(createContext({ 'a': 'x', 'b': { 'x': true } })), true);
|
||||
assert.equal(ainb.evaluate(createContext({ 'a': 'prototype', 'b': {} })), false);
|
||||
assert.strictEqual(ainb.evaluate(createContext({ 'a': 3, 'b': [3, 2, 1] })), true);
|
||||
assert.strictEqual(ainb.evaluate(createContext({ 'a': 3, 'b': [1, 2, 3] })), true);
|
||||
assert.strictEqual(ainb.evaluate(createContext({ 'a': 3, 'b': [1, 2] })), false);
|
||||
assert.strictEqual(ainb.evaluate(createContext({ 'a': 3 })), false);
|
||||
assert.strictEqual(ainb.evaluate(createContext({ 'a': 3, 'b': null })), false);
|
||||
assert.strictEqual(ainb.evaluate(createContext({ 'a': 'x', 'b': ['x'] })), true);
|
||||
assert.strictEqual(ainb.evaluate(createContext({ 'a': 'x', 'b': ['y'] })), false);
|
||||
assert.strictEqual(ainb.evaluate(createContext({ 'a': 'x', 'b': {} })), false);
|
||||
assert.strictEqual(ainb.evaluate(createContext({ 'a': 'x', 'b': { 'x': false } })), true);
|
||||
assert.strictEqual(ainb.evaluate(createContext({ 'a': 'x', 'b': { 'x': true } })), true);
|
||||
assert.strictEqual(ainb.evaluate(createContext({ 'a': 'prototype', 'b': {} })), false);
|
||||
});
|
||||
|
||||
test('issue #106524: distributing AND should normalize', () => {
|
||||
@@ -184,13 +184,13 @@ suite('ContextKeyExpr', () => {
|
||||
ContextKeyExpr.has('c')
|
||||
)
|
||||
);
|
||||
assert.equal(actual!.equals(expected!), true);
|
||||
assert.strictEqual(actual!.equals(expected!), true);
|
||||
});
|
||||
|
||||
test('Greater, GreaterEquals, Smaller, SmallerEquals evaluate', () => {
|
||||
function checkEvaluate(expr: string, ctx: any, expected: any): void {
|
||||
const _expr = ContextKeyExpr.deserialize(expr)!;
|
||||
assert.equal(_expr.evaluate(createContext(ctx)), expected);
|
||||
assert.strictEqual(_expr.evaluate(createContext(ctx)), expected);
|
||||
}
|
||||
|
||||
checkEvaluate('a>1', {}, false);
|
||||
@@ -236,7 +236,7 @@ suite('ContextKeyExpr', () => {
|
||||
function checkNegate(expr: string, expected: string): void {
|
||||
const a = ContextKeyExpr.deserialize(expr)!;
|
||||
const b = a.negate();
|
||||
assert.equal(b.serialize(), expected);
|
||||
assert.strictEqual(b.serialize(), expected);
|
||||
}
|
||||
|
||||
checkNegate('a>1', 'a <= 1');
|
||||
|
||||
Reference in New Issue
Block a user