mirror of
https://github.com/microsoft/vscode.git
synced 2026-03-03 07:19:22 +00:00
Remove no longer useful and confusing IKeybindingEvent (#151735)
Remove no longer useful and confusing `IKeybindingEvent` (fixes #151712)
This commit is contained in:
@@ -34,7 +34,7 @@ import { IContextKeyService, ContextKeyExpression } from 'vs/platform/contextkey
|
||||
import { IConfirmation, IConfirmationResult, IDialogOptions, IDialogService, IInputResult, IShowResult } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { createDecorator, IInstantiationService, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
|
||||
import { IKeybindingEvent, IKeybindingService, IKeyboardEvent, KeybindingSource, KeybindingsSchemaContribution } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IKeybindingService, IKeyboardEvent, KeybindingsSchemaContribution } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import { IKeybindingItem, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
|
||||
@@ -410,7 +410,7 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
|
||||
const kb = this._dynamicKeybindings[i];
|
||||
if (kb.command === commandId) {
|
||||
this._dynamicKeybindings.splice(i, 1);
|
||||
this.updateResolver({ source: KeybindingSource.Default });
|
||||
this.updateResolver();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -419,14 +419,14 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
|
||||
|
||||
toDispose.add(CommandsRegistry.registerCommand(commandId, handler));
|
||||
|
||||
this.updateResolver({ source: KeybindingSource.Default });
|
||||
this.updateResolver();
|
||||
|
||||
return toDispose;
|
||||
}
|
||||
|
||||
private updateResolver(event: IKeybindingEvent): void {
|
||||
private updateResolver(): void {
|
||||
this._cachedResolver = null;
|
||||
this._onDidUpdateKeybindings.fire(event);
|
||||
this._onDidUpdateKeybindings.fire();
|
||||
}
|
||||
|
||||
protected _getResolver(): KeybindingResolver {
|
||||
|
||||
@@ -13,7 +13,7 @@ import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import * as nls from 'vs/nls';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IContextKeyService, IContextKeyServiceTarget } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IKeybindingEvent, IKeybindingService, IKeyboardEvent, KeybindingsSchemaContribution } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IKeybindingService, IKeyboardEvent, KeybindingsSchemaContribution } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IResolveResult, KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
@@ -30,8 +30,8 @@ const HIGH_FREQ_COMMANDS = /^(cursor|delete)/;
|
||||
export abstract class AbstractKeybindingService extends Disposable implements IKeybindingService {
|
||||
public _serviceBrand: undefined;
|
||||
|
||||
protected readonly _onDidUpdateKeybindings: Emitter<IKeybindingEvent> = this._register(new Emitter<IKeybindingEvent>());
|
||||
get onDidUpdateKeybindings(): Event<IKeybindingEvent> {
|
||||
protected readonly _onDidUpdateKeybindings: Emitter<void> = this._register(new Emitter<void>());
|
||||
get onDidUpdateKeybindings(): Event<void> {
|
||||
return this._onDidUpdateKeybindings ? this._onDidUpdateKeybindings.event : Event.None; // Sinon stubbing walks properties on prototype
|
||||
}
|
||||
|
||||
|
||||
@@ -19,16 +19,6 @@ export interface IUserFriendlyKeybinding {
|
||||
when?: string;
|
||||
}
|
||||
|
||||
export const enum KeybindingSource {
|
||||
Default = 1,
|
||||
User
|
||||
}
|
||||
|
||||
export interface IKeybindingEvent {
|
||||
source: KeybindingSource;
|
||||
keybindings?: IUserFriendlyKeybinding[];
|
||||
}
|
||||
|
||||
export interface IKeyboardEvent {
|
||||
readonly _standardKeyboardEventBrand: true;
|
||||
|
||||
@@ -53,7 +43,7 @@ export interface IKeybindingService {
|
||||
|
||||
readonly inChordMode: boolean;
|
||||
|
||||
onDidUpdateKeybindings: Event<IKeybindingEvent>;
|
||||
onDidUpdateKeybindings: Event<void>;
|
||||
|
||||
/**
|
||||
* Returns none, one or many (depending on keyboard layout)!
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Event } from 'vs/base/common/event';
|
||||
import { Keybinding, ResolvedKeybinding, SimpleKeybinding } from 'vs/base/common/keybindings';
|
||||
import { OS } from 'vs/base/common/platform';
|
||||
import { ContextKeyExpression, ContextKeyValue, IContextKey, IContextKeyChangeEvent, IContextKeyService, IContextKeyServiceTarget } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IKeybindingEvent, IKeybindingService, IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IKeybindingService, IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IResolveResult } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
|
||||
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding';
|
||||
@@ -88,7 +88,7 @@ export class MockKeybindingService implements IKeybindingService {
|
||||
|
||||
public readonly inChordMode: boolean = false;
|
||||
|
||||
public get onDidUpdateKeybindings(): Event<IKeybindingEvent> {
|
||||
public get onDidUpdateKeybindings(): Event<void> {
|
||||
return Event.None;
|
||||
}
|
||||
|
||||
|
||||
@@ -147,20 +147,8 @@ export class CommandCenterControl {
|
||||
};
|
||||
menuUpdater();
|
||||
this._disposables.add(menu.onDidChange(menuUpdater));
|
||||
this._disposables.add(keybindingService.onDidUpdateKeybindings(e => {
|
||||
if (!e.keybindings?.length) {
|
||||
// when resetting a keybinding it isn't properly reported and we are better safe
|
||||
// than sorry. See https://github.com/microsoft/vscode/issues/151712
|
||||
menuUpdater();
|
||||
return;
|
||||
}
|
||||
const commands = new Set(e.keybindings.map(kb => kb.command));
|
||||
for (let i = 0, len = titleToolbar.getItemsLength(); i < len; i++) {
|
||||
if (commands.has(titleToolbar.getItemAction(i).id)) {
|
||||
menuUpdater();
|
||||
break;
|
||||
}
|
||||
}
|
||||
this._disposables.add(keybindingService.onDidUpdateKeybindings(() => {
|
||||
menuUpdater();
|
||||
}));
|
||||
this._disposables.add(quickInputService.onShow(this._setVisibility.bind(this, false)));
|
||||
this._disposables.add(quickInputService.onHide(this._setVisibility.bind(this, true)));
|
||||
|
||||
@@ -371,7 +371,7 @@ export class KeybindingsEditor extends EditorPane implements IKeybindingsEditorP
|
||||
getKeyBinding: action => this.keybindingsService.lookupKeybinding(action.id)
|
||||
}));
|
||||
toolBar.setActions(actions);
|
||||
this._register(this.keybindingsService.onDidUpdateKeybindings(e => toolBar.setActions(actions)));
|
||||
this._register(this.keybindingsService.onDidUpdateKeybindings(() => toolBar.setActions(actions)));
|
||||
}
|
||||
|
||||
private updateSearchOptions(): void {
|
||||
|
||||
@@ -175,7 +175,7 @@ export class KeybindingEditorDecorationsRenderer extends Disposable {
|
||||
|
||||
const model = assertIsDefined(this._editor.getModel());
|
||||
this._register(model.onDidChangeContent(() => this._updateDecorations.schedule()));
|
||||
this._register(this._keybindingService.onDidUpdateKeybindings((e) => this._updateDecorations.schedule()));
|
||||
this._register(this._keybindingService.onDidUpdateKeybindings(() => this._updateDecorations.schedule()));
|
||||
this._register({
|
||||
dispose: () => {
|
||||
this._dec.clear();
|
||||
|
||||
@@ -20,7 +20,7 @@ import { ContextKeyExpr, IContextKeyService, ContextKeyExpression, IContextKey }
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { Extensions, IJSONContributionRegistry } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
|
||||
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
|
||||
import { IKeyboardEvent, IUserFriendlyKeybinding, KeybindingSource, IKeybindingService, IKeybindingEvent, KeybindingsSchemaContribution } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IKeyboardEvent, IUserFriendlyKeybinding, IKeybindingService, KeybindingsSchemaContribution } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import { IKeybindingItem, IExtensionKeybindingRule, KeybindingWeight, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
|
||||
@@ -213,13 +213,13 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
|
||||
|
||||
dispatchConfig = newDispatchConfig;
|
||||
this._keyboardMapper = this.keyboardLayoutService.getKeyboardMapper(dispatchConfig);
|
||||
this.updateResolver({ source: KeybindingSource.Default });
|
||||
this.updateResolver();
|
||||
});
|
||||
|
||||
this._keyboardMapper = this.keyboardLayoutService.getKeyboardMapper(dispatchConfig);
|
||||
this.keyboardLayoutService.onDidChangeKeyboardLayout(() => {
|
||||
this._keyboardMapper = this.keyboardLayoutService.getKeyboardMapper(dispatchConfig);
|
||||
this.updateResolver({ source: KeybindingSource.Default });
|
||||
this.updateResolver();
|
||||
});
|
||||
|
||||
this._cachedResolver = null;
|
||||
@@ -227,15 +227,12 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
|
||||
this.userKeybindings = this._register(new UserKeybindings(environmentService.keybindingsResource, fileService, logService));
|
||||
this.userKeybindings.initialize().then(() => {
|
||||
if (this.userKeybindings.keybindings.length) {
|
||||
this.updateResolver({ source: KeybindingSource.User });
|
||||
this.updateResolver();
|
||||
}
|
||||
});
|
||||
this._register(this.userKeybindings.onDidChange(() => {
|
||||
logService.debug('User keybindings changed');
|
||||
this.updateResolver({
|
||||
source: KeybindingSource.User,
|
||||
keybindings: this.userKeybindings.keybindings
|
||||
});
|
||||
this.updateResolver();
|
||||
}));
|
||||
|
||||
keybindingsExtPoint.setHandler((extensions) => {
|
||||
@@ -246,7 +243,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
|
||||
}
|
||||
|
||||
KeybindingsRegistry.setExtensionKeybindings(keybindings);
|
||||
this.updateResolver({ source: KeybindingSource.Default });
|
||||
this.updateResolver();
|
||||
});
|
||||
|
||||
this.updateSchema();
|
||||
@@ -291,7 +288,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
|
||||
|
||||
// update resolver which will bring back all unbound keyboard shortcuts
|
||||
this._cachedResolver = null;
|
||||
this._onDidUpdateKeybindings.fire({ source: KeybindingSource.User });
|
||||
this._onDidUpdateKeybindings.fire();
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -397,9 +394,9 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
|
||||
return this.userKeybindings.keybindings.length;
|
||||
}
|
||||
|
||||
private updateResolver(event: IKeybindingEvent): void {
|
||||
private updateResolver(): void {
|
||||
this._cachedResolver = null;
|
||||
this._onDidUpdateKeybindings.fire(event);
|
||||
this._onDidUpdateKeybindings.fire();
|
||||
}
|
||||
|
||||
protected _getResolver(): KeybindingResolver {
|
||||
|
||||
Reference in New Issue
Block a user