Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)

* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973

* disable strict null check
This commit is contained in:
Anthony Dresser
2019-07-15 22:35:46 -07:00
committed by GitHub
parent f720ec642f
commit 0b7e7ddbf9
2406 changed files with 59140 additions and 35464 deletions

View File

@@ -15,8 +15,8 @@ import { IKeybindingEvent, IKeybindingService, IKeyboardEvent } from 'vs/platfor
import { IResolveResult, KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification } from 'vs/base/common/actions';
interface CurrentChord {
keypress: string;
@@ -26,51 +26,39 @@ interface CurrentChord {
export abstract class AbstractKeybindingService extends Disposable implements IKeybindingService {
public _serviceBrand: any;
protected readonly _onDidUpdateKeybindings: Emitter<IKeybindingEvent> = this._register(new Emitter<IKeybindingEvent>());
get onDidUpdateKeybindings(): Event<IKeybindingEvent> {
return this._onDidUpdateKeybindings ? this._onDidUpdateKeybindings.event : Event.None; // Sinon stubbing walks properties on prototype
}
private _currentChord: CurrentChord | null;
private _currentChordChecker: IntervalTimer;
private _currentChordStatusMessage: IDisposable | null;
protected _onDidUpdateKeybindings: Emitter<IKeybindingEvent>;
private _contextKeyService: IContextKeyService;
private _statusService: IStatusbarService | undefined;
private _notificationService: INotificationService;
protected _commandService: ICommandService;
protected _telemetryService: ITelemetryService;
constructor(
contextKeyService: IContextKeyService,
commandService: ICommandService,
telemetryService: ITelemetryService,
notificationService: INotificationService,
statusService?: IStatusbarService
private _contextKeyService: IContextKeyService,
protected _commandService: ICommandService,
protected _telemetryService: ITelemetryService,
private _notificationService: INotificationService,
) {
super();
this._contextKeyService = contextKeyService;
this._commandService = commandService;
this._telemetryService = telemetryService;
this._statusService = statusService;
this._notificationService = notificationService;
this._currentChord = null;
this._currentChordChecker = new IntervalTimer();
this._currentChordStatusMessage = null;
this._onDidUpdateKeybindings = this._register(new Emitter<IKeybindingEvent>());
}
public dispose(): void {
super.dispose();
}
get onDidUpdateKeybindings(): Event<IKeybindingEvent> {
return this._onDidUpdateKeybindings ? this._onDidUpdateKeybindings.event : Event.None; // Sinon stubbing walks properties on prototype
}
protected abstract _getResolver(): KeybindingResolver;
protected abstract _documentHasFocus(): boolean;
public abstract resolveKeybinding(keybinding: Keybinding): ResolvedKeybinding[];
public abstract resolveKeyboardEvent(keyboardEvent: IKeyboardEvent): ResolvedKeybinding;
public abstract resolveUserBinding(userBinding: string): ResolvedKeybinding[];
public abstract _dumpDebugInfo(): string;
public abstract _dumpDebugInfoJSON(): string;
public getDefaultKeybindingsContent(): string {
return '';
@@ -128,9 +116,7 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
keypress: firstPart,
label: keypressLabel
};
if (this._statusService) {
this._currentChordStatusMessage = this._statusService.setStatusMessage(nls.localize('first.chord', "({0}) was pressed. Waiting for second key of chord...", keypressLabel));
}
this._currentChordStatusMessage = this._notificationService.status(nls.localize('first.chord', "({0}) was pressed. Waiting for second key of chord...", keypressLabel));
const chordEnterTime = Date.now();
this._currentChordChecker.cancelAndSet(() => {
@@ -192,9 +178,9 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
return shouldPreventDefault;
}
if (this._statusService && this._currentChord) {
if (this._currentChord) {
if (!resolveResult || !resolveResult.commandId) {
this._statusService.setStatusMessage(nls.localize('missing.chord', "The key combination ({0}, {1}) is not a command.", this._currentChord.label, keypressLabel), 10 * 1000 /* 10s */);
this._notificationService.status(nls.localize('missing.chord', "The key combination ({0}, {1}) is not a command.", this._currentChord.label, keypressLabel), { hideAfter: 10 * 1000 /* 10s */ });
shouldPreventDefault = true;
}
}
@@ -210,13 +196,7 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
} else {
this._commandService.executeCommand(resolveResult.commandId, resolveResult.commandArgs).then(undefined, err => this._notificationService.warn(err));
}
/* __GDPR__
"workbenchActionExecuted" : {
"id" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"from": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
this._telemetryService.publicLog('workbenchActionExecuted', { id: resolveResult.commandId, from: 'keybinding' });
this._telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: resolveResult.commandId, from: 'keybinding' });
}
return shouldPreventDefault;

View File

@@ -93,5 +93,6 @@ export interface IKeybindingService {
mightProducePrintableCharacter(event: IKeyboardEvent): boolean;
_dumpDebugInfo(): string;
_dumpDebugInfoJSON(): string;
}

View File

@@ -8,6 +8,7 @@ import { MenuRegistry } from 'vs/platform/actions/common/actions';
import { CommandsRegistry, ICommandHandlerDescription } from 'vs/platform/commands/common/commands';
import { ContextKeyAndExpr, ContextKeyExpr, IContext } from 'vs/platform/contextkey/common/contextkey';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
import { keys } from 'vs/base/common/map';
export interface IResolveResult {
enterChord: boolean;
@@ -334,10 +335,10 @@ export class KeybindingResolver {
}
unboundCommands.push(id);
};
for (const id in MenuRegistry.getCommands()) {
for (const id of keys(MenuRegistry.getCommands())) {
addCommand(id, true);
}
for (const id in CommandsRegistry.getCommands()) {
for (const id of keys(CommandsRegistry.getCommands())) {
addCommand(id, false);
}

View File

@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { KeyChord, KeyCode, KeyMod, Keybinding, ResolvedKeybinding, SimpleKeybinding, createKeybinding, createSimpleKeybinding } from 'vs/base/common/keyCodes';
import { IDisposable } from 'vs/base/common/lifecycle';
import { OS } from 'vs/base/common/platform';
import Severity from 'vs/base/common/severity';
import { ICommandService } from 'vs/platform/commands/common/commands';
@@ -14,9 +13,9 @@ import { IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding';
import { INotification, INotificationService, IPromptChoice, IPromptOptions, NoOpNotification } from 'vs/platform/notification/common/notification';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { INotification, INotificationService, IPromptChoice, IPromptOptions, NoOpNotification, IStatusMessageOptions } from 'vs/platform/notification/common/notification';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
function createContext(ctx: any) {
return {
@@ -35,10 +34,9 @@ suite('AbstractKeybindingService', () => {
resolver: KeybindingResolver,
contextKeyService: IContextKeyService,
commandService: ICommandService,
notificationService: INotificationService,
statusService?: IStatusbarService
notificationService: INotificationService
) {
super(contextKeyService, commandService, NullTelemetryService, notificationService, statusService);
super(contextKeyService, commandService, NullTelemetryService, notificationService);
this._resolver = resolver;
}
@@ -85,6 +83,10 @@ suite('AbstractKeybindingService', () => {
public _dumpDebugInfo(): string {
return '';
}
public _dumpDebugInfoJSON(): string {
return '';
}
}
let createTestKeybindingService: (items: ResolvedKeybindingItem[], contextValue?: any) => TestKeybindingService = null!;
@@ -129,7 +131,7 @@ suite('AbstractKeybindingService', () => {
};
let notificationService: INotificationService = {
_serviceBrand: undefined,
_serviceBrand: {} as ServiceIdentifier<INotificationService>,
notify: (notification: INotification) => {
showMessageCalls.push({ sev: notification.severity, message: notification.message });
return new NoOpNotification();
@@ -148,13 +150,8 @@ suite('AbstractKeybindingService', () => {
},
prompt(severity: Severity, message: string, choices: IPromptChoice[], options?: IPromptOptions) {
throw new Error('not implemented');
}
};
let statusbarService: IStatusbarService = {
_serviceBrand: undefined,
addEntry: undefined!,
setStatusMessage: (message: string, autoDisposeAfter?: number, delayBy?: number): IDisposable => {
},
status(message: string, options?: IStatusMessageOptions) {
statusMessageCalls!.push(message);
return {
dispose: () => {
@@ -166,7 +163,7 @@ suite('AbstractKeybindingService', () => {
let resolver = new KeybindingResolver(items, []);
return new TestKeybindingService(resolver, contextKeyService, commandService, notificationService, statusbarService);
return new TestKeybindingService(resolver, contextKeyService, commandService, notificationService);
};
});

View File

@@ -137,4 +137,8 @@ export class MockKeybindingService implements IKeybindingService {
public _dumpDebugInfo(): string {
return '';
}
public _dumpDebugInfoJSON(): string {
return '';
}
}