Skip to content

Commit 4fbb52b

Browse files
committed
add trace logging to know what keybinding triggers what command, fyi @alexdima
1 parent ab2f68f commit 4fbb52b

4 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/vs/editor/standalone/browser/simpleServices.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { SimpleServicesNLS } from 'vs/editor/common/standaloneStrings';
4646
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
4747
import { basename } from 'vs/base/common/resources';
4848
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
49+
import { NullLogService } from 'vs/platform/log/common/log';
4950

5051
export class SimpleModel implements IResolvedTextEditorModel {
5152

@@ -292,7 +293,7 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
292293
notificationService: INotificationService,
293294
domNode: HTMLElement
294295
) {
295-
super(contextKeyService, commandService, telemetryService, notificationService);
296+
super(contextKeyService, commandService, telemetryService, notificationService, new NullLogService());
296297

297298
this._cachedResolver = null;
298299
this._dynamicKeybindings = [];

src/vs/platform/keybinding/common/abstractKeybindingService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKe
1717
import { INotificationService } from 'vs/platform/notification/common/notification';
1818
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1919
import { WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification } from 'vs/base/common/actions';
20+
import { ILogService } from 'vs/platform/log/common/log';
2021

2122
interface CurrentChord {
2223
keypress: string;
@@ -44,6 +45,7 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
4445
protected _commandService: ICommandService,
4546
protected _telemetryService: ITelemetryService,
4647
private _notificationService: INotificationService,
48+
protected _logService: ILogService,
4749
) {
4850
super();
4951

@@ -177,6 +179,8 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
177179
const keypressLabel = keybinding.getLabel();
178180
const resolveResult = this._getResolver().resolve(contextValue, currentChord, firstPart);
179181

182+
this._logService.trace('KeybindingService#dispatch', keypressLabel, resolveResult?.commandId);
183+
180184
if (resolveResult && resolveResult.enterChord) {
181185
shouldPreventDefault = true;
182186
this._enterChordMode(firstPart, keypressLabel);

src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayo
1616
import { INotification, INotificationService, IPromptChoice, IPromptOptions, NoOpNotification, IStatusMessageOptions } from 'vs/platform/notification/common/notification';
1717
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
1818
import { Disposable } from 'vs/base/common/lifecycle';
19+
import { NullLogService } from 'vs/platform/log/common/log';
1920

2021
function createContext(ctx: any) {
2122
return {
@@ -36,7 +37,7 @@ suite('AbstractKeybindingService', () => {
3637
commandService: ICommandService,
3738
notificationService: INotificationService
3839
) {
39-
super(contextKeyService, commandService, NullTelemetryService, notificationService);
40+
super(contextKeyService, commandService, NullTelemetryService, notificationService, new NullLogService());
4041
this._resolver = resolver;
4142
}
4243

src/vs/workbench/services/keybinding/browser/keybindingService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
194194
@ILogService logService: ILogService,
195195
@IKeymapService private readonly keymapService: IKeymapService
196196
) {
197-
super(contextKeyService, commandService, telemetryService, notificationService);
197+
super(contextKeyService, commandService, telemetryService, notificationService, logService);
198198

199199
this.updateSchema();
200200

0 commit comments

Comments
 (0)