"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/vs/platform/keybinding/common/abstractKeybindingService.ts" between
vscode-1.48.2.tar.gz and vscode-1.49.0.tar.gz

About: Visual Studio Code is a source code editor (available for Windows, macOS and Linux). It comes with built-in support for JavaScript, TypeScript and Node.js and has extensions for other languages (such as C++, C#, Java, Python, PHP, Go). Source code.

abstractKeybindingService.ts  (vscode-1.48.2):abstractKeybindingService.ts  (vscode-1.49.0)
skipping to change at line 20 skipping to change at line 20
import { KeyCode, Keybinding, ResolvedKeybinding } from 'vs/base/common/keyCodes '; import { KeyCode, Keybinding, ResolvedKeybinding } from 'vs/base/common/keyCodes ';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { ICommandService } from 'vs/platform/commands/common/commands'; import { ICommandService } from 'vs/platform/commands/common/commands';
import { IContextKeyService, IContextKeyServiceTarget } from 'vs/platform/contex tkey/common/contextkey'; import { IContextKeyService, IContextKeyServiceTarget } from 'vs/platform/contex tkey/common/contextkey';
import { IKeybindingEvent, IKeybindingService, IKeyboardEvent, KeybindingsSchema Contribution } from 'vs/platform/keybinding/common/keybinding'; import { IKeybindingEvent, IKeybindingService, IKeyboardEvent, KeybindingsSchema Contribution } from 'vs/platform/keybinding/common/keybinding';
import { IResolveResult, KeybindingResolver } from 'vs/platform/keybinding/commo n/keybindingResolver'; import { IResolveResult, KeybindingResolver } from 'vs/platform/keybinding/commo n/keybindingResolver';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKe ybindingItem'; import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKe ybindingItem';
import { INotificationService } from 'vs/platform/notification/common/notificati on'; import { INotificationService } from 'vs/platform/notification/common/notificati on';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification } f rom 'vs/base/common/actions'; import { WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification } f rom 'vs/base/common/actions';
import { ILogService } from 'vs/platform/log/common/log';
interface CurrentChord { interface CurrentChord {
keypress: string; keypress: string;
label: string | null; label: string | null;
} }
export abstract class AbstractKeybindingService extends Disposable implements IK eybindingService { export abstract class AbstractKeybindingService extends Disposable implements IK eybindingService {
public _serviceBrand: undefined; public _serviceBrand: undefined;
protected readonly _onDidUpdateKeybindings: Emitter<IKeybindingEvent> = t his._register(new Emitter<IKeybindingEvent>()); protected readonly _onDidUpdateKeybindings: Emitter<IKeybindingEvent> = t his._register(new Emitter<IKeybindingEvent>());
get onDidUpdateKeybindings(): Event<IKeybindingEvent> { get onDidUpdateKeybindings(): Event<IKeybindingEvent> {
return this._onDidUpdateKeybindings ? this._onDidUpdateKeybinding s.event : Event.None; // Sinon stubbing walks properties on prototype return this._onDidUpdateKeybindings ? this._onDidUpdateKeybinding s.event : Event.None; // Sinon stubbing walks properties on prototype
} }
private _currentChord: CurrentChord | null; private _currentChord: CurrentChord | null;
private _currentChordChecker: IntervalTimer; private _currentChordChecker: IntervalTimer;
private _currentChordStatusMessage: IDisposable | null; private _currentChordStatusMessage: IDisposable | null;
protected _logging: boolean;
public get inChordMode(): boolean { public get inChordMode(): boolean {
return !!this._currentChord; return !!this._currentChord;
} }
constructor( constructor(
private _contextKeyService: IContextKeyService, private _contextKeyService: IContextKeyService,
protected _commandService: ICommandService, protected _commandService: ICommandService,
protected _telemetryService: ITelemetryService, protected _telemetryService: ITelemetryService,
private _notificationService: INotificationService, private _notificationService: INotificationService,
protected _logService: ILogService,
) { ) {
super(); super();
this._currentChord = null; this._currentChord = null;
this._currentChordChecker = new IntervalTimer(); this._currentChordChecker = new IntervalTimer();
this._currentChordStatusMessage = null; this._currentChordStatusMessage = null;
this._logging = false;
} }
public dispose(): void { public dispose(): void {
super.dispose(); super.dispose();
} }
protected abstract _getResolver(): KeybindingResolver; protected abstract _getResolver(): KeybindingResolver;
protected abstract _documentHasFocus(): boolean; protected abstract _documentHasFocus(): boolean;
public abstract resolveKeybinding(keybinding: Keybinding): ResolvedKeybin ding[]; public abstract resolveKeybinding(keybinding: Keybinding): ResolvedKeybin ding[];
public abstract resolveKeyboardEvent(keyboardEvent: IKeyboardEvent): Reso lvedKeybinding; public abstract resolveKeyboardEvent(keyboardEvent: IKeyboardEvent): Reso lvedKeybinding;
public abstract resolveUserBinding(userBinding: string): ResolvedKeybindi ng[]; public abstract resolveUserBinding(userBinding: string): ResolvedKeybindi ng[];
public abstract registerSchemaContribution(contribution: KeybindingsSchem aContribution): void; public abstract registerSchemaContribution(contribution: KeybindingsSchem aContribution): void;
public abstract _dumpDebugInfo(): string; public abstract _dumpDebugInfo(): string;
public abstract _dumpDebugInfoJSON(): string; public abstract _dumpDebugInfoJSON(): string;
public getDefaultKeybindingsContent(): string { public getDefaultKeybindingsContent(): string {
return ''; return '';
} }
public toggleLogging(): boolean {
this._logging = !this._logging;
return this._logging;
}
protected _log(str: string): void {
if (this._logging) {
this._logService.info(`[KeybindingService]: ${str}`);
}
}
public getDefaultKeybindings(): readonly ResolvedKeybindingItem[] { public getDefaultKeybindings(): readonly ResolvedKeybindingItem[] {
return this._getResolver().getDefaultKeybindings(); return this._getResolver().getDefaultKeybindings();
} }
public getKeybindings(): readonly ResolvedKeybindingItem[] { public getKeybindings(): readonly ResolvedKeybindingItem[] {
return this._getResolver().getKeybindings(); return this._getResolver().getKeybindings();
} }
public customKeybindingsCount(): number { public customKeybindingsCount(): number {
return 0; return 0;
skipping to change at line 171 skipping to change at line 186
private _doDispatch(keybinding: ResolvedKeybinding, target: IContextKeySe rviceTarget): boolean { private _doDispatch(keybinding: ResolvedKeybinding, target: IContextKeySe rviceTarget): boolean {
let shouldPreventDefault = false; let shouldPreventDefault = false;
if (keybinding.isChord()) { if (keybinding.isChord()) {
console.warn('Unexpected keyboard event mapped to a chord '); console.warn('Unexpected keyboard event mapped to a chord ');
return false; return false;
} }
const [firstPart,] = keybinding.getDispatchParts(); const [firstPart,] = keybinding.getDispatchParts();
if (firstPart === null) { if (firstPart === null) {
this._log(`\\ Keyboard event cannot be dispatched.`);
// cannot be dispatched, probably only modifier keys // cannot be dispatched, probably only modifier keys
return shouldPreventDefault; return shouldPreventDefault;
} }
const contextValue = this._contextKeyService.getContext(target); const contextValue = this._contextKeyService.getContext(target);
const currentChord = this._currentChord ? this._currentChord.keyp ress : null; const currentChord = this._currentChord ? this._currentChord.keyp ress : null;
const keypressLabel = keybinding.getLabel(); const keypressLabel = keybinding.getLabel();
const resolveResult = this._getResolver().resolve(contextValue, c urrentChord, firstPart); const resolveResult = this._getResolver().resolve(contextValue, c urrentChord, firstPart);
this._logService.trace('KeybindingService#dispatch', keypressLabe
l, resolveResult?.commandId);
if (resolveResult && resolveResult.enterChord) { if (resolveResult && resolveResult.enterChord) {
shouldPreventDefault = true; shouldPreventDefault = true;
this._enterChordMode(firstPart, keypressLabel); this._enterChordMode(firstPart, keypressLabel);
return shouldPreventDefault; return shouldPreventDefault;
} }
if (this._currentChord) { if (this._currentChord) {
if (!resolveResult || !resolveResult.commandId) { if (!resolveResult || !resolveResult.commandId) {
this._notificationService.status(nls.localize('mi ssing.chord', "The key combination ({0}, {1}) is not a command.", this._currentC hord.label, keypressLabel), { hideAfter: 10 * 1000 /* 10s */ }); this._notificationService.status(nls.localize('mi ssing.chord', "The key combination ({0}, {1}) is not a command.", this._currentC hord.label, keypressLabel), { hideAfter: 10 * 1000 /* 10s */ });
shouldPreventDefault = true; shouldPreventDefault = true;
 End of changes. 7 change blocks. 
0 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)