Merge VS Code 1.31.1 (#4283)

This commit is contained in:
Matt Irvine
2019-03-15 13:09:45 -07:00
committed by GitHub
parent 7d31575149
commit 86bac90001
1716 changed files with 53308 additions and 48375 deletions

View File

@@ -72,7 +72,7 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
// add argument validation if rich command metadata is provided
if (idOrCommand.description) {
const constraints: (TypeConstraint | undefined)[] = [];
const constraints: Array<TypeConstraint | undefined> = [];
for (let arg of idOrCommand.description.args) {
constraints.push(arg.constraint);
}
@@ -96,7 +96,8 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
let ret = toDisposable(() => {
removeFn();
if (this._commands.get(id).isEmpty()) {
const command = this._commands.get(id);
if (command && command.isEmpty()) {
this._commands.delete(id);
}
});
@@ -108,9 +109,7 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
}
registerCommandAlias(oldId: string, newId: string): IDisposable {
return CommandsRegistry.registerCommand(oldId, (accessor, ...args) => {
accessor.get(ICommandService).executeCommand(newId, ...args);
});
return CommandsRegistry.registerCommand(oldId, (accessor, ...args) => accessor.get(ICommandService).executeCommand(newId, ...args));
}
getCommand(id: string): ICommand | undefined {

View File

@@ -8,13 +8,13 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands';
suite('Command Tests', function () {
test('register command - no handler', function () {
assert.throws(() => CommandsRegistry.registerCommand('foo', null));
assert.throws(() => CommandsRegistry.registerCommand('foo', null!));
});
test('register/dispose', () => {
const command = function () { };
const reg = CommandsRegistry.registerCommand('foo', command);
assert.ok(CommandsRegistry.getCommand('foo').handler === command);
assert.ok(CommandsRegistry.getCommand('foo')!.handler === command);
reg.dispose();
assert.ok(CommandsRegistry.getCommand('foo') === undefined);
});
@@ -25,26 +25,26 @@ suite('Command Tests', function () {
// dispose overriding command
let reg1 = CommandsRegistry.registerCommand('foo', command1);
assert.ok(CommandsRegistry.getCommand('foo').handler === command1);
assert.ok(CommandsRegistry.getCommand('foo')!.handler === command1);
let reg2 = CommandsRegistry.registerCommand('foo', command2);
assert.ok(CommandsRegistry.getCommand('foo').handler === command2);
assert.ok(CommandsRegistry.getCommand('foo')!.handler === command2);
reg2.dispose();
assert.ok(CommandsRegistry.getCommand('foo').handler === command1);
assert.ok(CommandsRegistry.getCommand('foo')!.handler === command1);
reg1.dispose();
assert.ok(CommandsRegistry.getCommand('foo') === void 0);
assert.ok(CommandsRegistry.getCommand('foo') === undefined);
// dispose override command first
reg1 = CommandsRegistry.registerCommand('foo', command1);
reg2 = CommandsRegistry.registerCommand('foo', command2);
assert.ok(CommandsRegistry.getCommand('foo').handler === command2);
assert.ok(CommandsRegistry.getCommand('foo')!.handler === command2);
reg1.dispose();
assert.ok(CommandsRegistry.getCommand('foo').handler === command2);
assert.ok(CommandsRegistry.getCommand('foo')!.handler === command2);
reg2.dispose();
assert.ok(CommandsRegistry.getCommand('foo') === void 0);
assert.ok(CommandsRegistry.getCommand('foo') === undefined);
});
test('command with description', function () {
@@ -68,10 +68,10 @@ suite('Command Tests', function () {
}
});
CommandsRegistry.getCommands()['test'].handler.apply(undefined, [undefined, 'string']);
CommandsRegistry.getCommands()['test2'].handler.apply(undefined, [undefined, 'string']);
assert.throws(() => CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined, 'string']));
assert.equal(CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined, 1]), true);
CommandsRegistry.getCommands()['test'].handler.apply(undefined, [undefined!, 'string']);
CommandsRegistry.getCommands()['test2'].handler.apply(undefined, [undefined!, 'string']);
assert.throws(() => CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined!, 'string']));
assert.equal(CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined!, 1]), true);
});
});