mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { Event, Emitter, debounceEvent, EventBufferer, once, fromPromise, stopwatch, buffer, echo, EventMultiplexer, latch, AsyncEmitter, IWaitUntil } from 'vs/base/common/event';
|
||||
import { Event, Emitter, EventBufferer, EventMultiplexer, AsyncEmitter, IWaitUntil } from 'vs/base/common/event';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import * as Errors from 'vs/base/common/errors';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
@@ -71,7 +71,7 @@ suite('Event', function () {
|
||||
|
||||
// unhook listener
|
||||
while (bucket.length) {
|
||||
bucket.pop().dispose();
|
||||
bucket.pop()!.dispose();
|
||||
}
|
||||
|
||||
// noop
|
||||
@@ -111,7 +111,7 @@ suite('Event', function () {
|
||||
Errors.setUnexpectedErrorHandler(() => null);
|
||||
|
||||
try {
|
||||
let a = new Emitter();
|
||||
let a = new Emitter<undefined>();
|
||||
let hit = false;
|
||||
a.event(function () {
|
||||
throw 9;
|
||||
@@ -134,26 +134,26 @@ suite('Event', function () {
|
||||
}
|
||||
const context = {};
|
||||
|
||||
let emitter = new Emitter();
|
||||
let emitter = new Emitter<undefined>();
|
||||
let reg1 = emitter.event(listener, context);
|
||||
let reg2 = emitter.event(listener, context);
|
||||
|
||||
emitter.fire();
|
||||
emitter.fire(undefined);
|
||||
assert.equal(counter, 2);
|
||||
|
||||
reg1.dispose();
|
||||
emitter.fire();
|
||||
emitter.fire(undefined);
|
||||
assert.equal(counter, 3);
|
||||
|
||||
reg2.dispose();
|
||||
emitter.fire();
|
||||
emitter.fire(undefined);
|
||||
assert.equal(counter, 3);
|
||||
});
|
||||
|
||||
test('Debounce Event', function (done: () => void) {
|
||||
let doc = new Samples.Document3();
|
||||
|
||||
let onDocDidChange = debounceEvent(doc.onDidChange, (prev: string[], cur) => {
|
||||
let onDocDidChange = Event.debounce(doc.onDidChange, (prev: string[], cur) => {
|
||||
if (!prev) {
|
||||
prev = [cur];
|
||||
} else if (prev.indexOf(cur) < 0) {
|
||||
@@ -183,7 +183,7 @@ suite('Event', function () {
|
||||
|
||||
test('Debounce Event - leading', async function () {
|
||||
const emitter = new Emitter<void>();
|
||||
let debounced = debounceEvent(emitter.event, (l, e) => e, 0, /*leading=*/true);
|
||||
let debounced = Event.debounce(emitter.event, (l, e) => e, 0, /*leading=*/true);
|
||||
|
||||
let calls = 0;
|
||||
debounced(() => {
|
||||
@@ -199,7 +199,7 @@ suite('Event', function () {
|
||||
|
||||
test('Debounce Event - leading', async function () {
|
||||
const emitter = new Emitter<void>();
|
||||
let debounced = debounceEvent(emitter.event, (l, e) => e, 0, /*leading=*/true);
|
||||
let debounced = Event.debounce(emitter.event, (l, e) => e, 0, /*leading=*/true);
|
||||
|
||||
let calls = 0;
|
||||
debounced(() => {
|
||||
@@ -254,7 +254,7 @@ suite('AsyncEmitter', function () {
|
||||
emitter.fireAsync(thenables => ({
|
||||
foo: true,
|
||||
bar: 1,
|
||||
waitUntil(t: Thenable<void>) { thenables.push(t); }
|
||||
waitUntil(t: Promise<void>) { thenables.push(t); }
|
||||
}));
|
||||
emitter.dispose();
|
||||
});
|
||||
@@ -384,8 +384,8 @@ suite('Event utils', () => {
|
||||
let counter1 = 0, counter2 = 0, counter3 = 0;
|
||||
|
||||
const listener1 = emitter.event(() => counter1++);
|
||||
const listener2 = once(emitter.event)(() => counter2++);
|
||||
const listener3 = once(emitter.event)(() => counter3++);
|
||||
const listener2 = Event.once(emitter.event)(() => counter2++);
|
||||
const listener3 = Event.once(emitter.event)(() => counter3++);
|
||||
|
||||
assert.equal(counter1, 0);
|
||||
assert.equal(counter2, 0);
|
||||
@@ -412,7 +412,7 @@ suite('Event utils', () => {
|
||||
test('should emit when done', async () => {
|
||||
let count = 0;
|
||||
|
||||
const event = fromPromise(Promise.resolve(null));
|
||||
const event = Event.fromPromise(Promise.resolve(null));
|
||||
event(() => count++);
|
||||
|
||||
assert.equal(count, 0);
|
||||
@@ -425,7 +425,7 @@ suite('Event utils', () => {
|
||||
let count = 0;
|
||||
|
||||
const promise = timeout(5);
|
||||
const event = fromPromise(promise);
|
||||
const event = Event.fromPromise(promise);
|
||||
event(() => count++);
|
||||
|
||||
assert.equal(count, 0);
|
||||
@@ -438,7 +438,7 @@ suite('Event utils', () => {
|
||||
|
||||
test('should emit', () => {
|
||||
const emitter = new Emitter<void>();
|
||||
const event = stopwatch(emitter.event);
|
||||
const event = Event.stopwatch(emitter.event);
|
||||
|
||||
return new Promise((c, e) => {
|
||||
event(duration => {
|
||||
@@ -448,7 +448,7 @@ suite('Event utils', () => {
|
||||
e(err);
|
||||
}
|
||||
|
||||
c(null);
|
||||
c(undefined);
|
||||
});
|
||||
|
||||
setTimeout(() => emitter.fire(), 10);
|
||||
@@ -462,7 +462,7 @@ suite('Event utils', () => {
|
||||
const result: number[] = [];
|
||||
const emitter = new Emitter<number>();
|
||||
const event = emitter.event;
|
||||
const bufferedEvent = buffer(event);
|
||||
const bufferedEvent = Event.buffer(event);
|
||||
|
||||
emitter.fire(1);
|
||||
emitter.fire(2);
|
||||
@@ -484,7 +484,7 @@ suite('Event utils', () => {
|
||||
const result: number[] = [];
|
||||
const emitter = new Emitter<number>();
|
||||
const event = emitter.event;
|
||||
const bufferedEvent = buffer(event, true);
|
||||
const bufferedEvent = Event.buffer(event, true);
|
||||
|
||||
emitter.fire(1);
|
||||
emitter.fire(2);
|
||||
@@ -506,7 +506,7 @@ suite('Event utils', () => {
|
||||
const result: number[] = [];
|
||||
const emitter = new Emitter<number>();
|
||||
const event = emitter.event;
|
||||
const bufferedEvent = buffer(event, false, [-2, -1, 0]);
|
||||
const bufferedEvent = Event.buffer(event, false, [-2, -1, 0]);
|
||||
|
||||
emitter.fire(1);
|
||||
emitter.fire(2);
|
||||
@@ -524,7 +524,7 @@ suite('Event utils', () => {
|
||||
const result: number[] = [];
|
||||
const emitter = new Emitter<number>();
|
||||
const event = emitter.event;
|
||||
const echoEvent = echo(event);
|
||||
const echoEvent = Event.echo(event);
|
||||
|
||||
emitter.fire(1);
|
||||
emitter.fire(2);
|
||||
@@ -547,7 +547,7 @@ suite('Event utils', () => {
|
||||
const result2: number[] = [];
|
||||
const emitter = new Emitter<number>();
|
||||
const event = emitter.event;
|
||||
const echoEvent = echo(event);
|
||||
const echoEvent = Event.echo(event);
|
||||
|
||||
emitter.fire(1);
|
||||
emitter.fire(2);
|
||||
@@ -744,7 +744,7 @@ suite('Event utils', () => {
|
||||
|
||||
test('latch', () => {
|
||||
const emitter = new Emitter<number>();
|
||||
const event = latch(emitter.event);
|
||||
const event = Event.latch(emitter.event);
|
||||
|
||||
const result: number[] = [];
|
||||
const listener = event(num => result.push(num));
|
||||
|
||||
Reference in New Issue
Block a user