diff --git a/src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts b/src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts index ff505690d807..7e8a05cdce05 100644 --- a/src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts +++ b/src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts @@ -7,3 +7,4 @@ import './electron-browser/toggleRenderControlCharacter'; import './electron-browser/toggleRenderWhitespace'; import './electron-browser/toggleWordWrap'; import './electron-browser/wordWrapMigration'; +import './electron-browser/inspectKeybindings'; diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/inspectKeybindings.ts b/src/vs/workbench/parts/codeEditor/electron-browser/inspectKeybindings.ts new file mode 100644 index 000000000000..8b8314e6b82f --- /dev/null +++ b/src/vs/workbench/parts/codeEditor/electron-browser/inspectKeybindings.ts @@ -0,0 +1,42 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import * as nls from 'vs/nls'; +import { ICommonCodeEditor } from 'vs/editor/common/editorCommon'; +import { editorAction, ServicesAccessor, EditorAction } from 'vs/editor/common/editorCommonExtensions'; +import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; +import { WorkbenchKeybindingService } from 'vs/workbench/services/keybinding/electron-browser/keybindingService'; +import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; +import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; +import URI from 'vs/base/common/uri'; +import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput'; + +@editorAction +class InspectKeyMap extends EditorAction { + + constructor() { + super({ + id: 'workbench.action.inspectKeyMappings', + label: nls.localize('workbench.action.inspectKeyMap', "Developer: Inspect Key Mapppings"), + alias: 'Developer: Inspect Key Mapppings', + precondition: null + }); + } + + public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void { + const keybindingService = accessor.get(IKeybindingService); + const editorService = accessor.get(IWorkbenchEditorService); + const untitledEditorService = accessor.get(IUntitledEditorService); + + if (keybindingService instanceof WorkbenchKeybindingService) { + console.log(keybindingService.dumpDebugInfo()); + + const resource = URI.from({ scheme: UntitledEditorInput.SCHEMA, path: `KeyMap` }); + const input = untitledEditorService.createOrGet(resource, null, keybindingService.dumpDebugInfo()); + editorService.openEditor(input, { pinned: true }); + } + } +} diff --git a/src/vs/workbench/services/keybinding/common/keyboardMapper.ts b/src/vs/workbench/services/keybinding/common/keyboardMapper.ts index c31a69a2ac3a..606249d11b9b 100644 --- a/src/vs/workbench/services/keybinding/common/keyboardMapper.ts +++ b/src/vs/workbench/services/keybinding/common/keyboardMapper.ts @@ -9,6 +9,7 @@ import { Keybinding, ResolvedKeybinding } from 'vs/base/common/keyCodes'; import { IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding'; export interface IKeyboardMapper { + dumpRawDebugInfo(): string; dumpDebugInfo(): string; resolveKeybinding(keybinding: Keybinding): ResolvedKeybinding[]; resolveKeyboardEvent(keyboardEvent: IKeyboardEvent): ResolvedKeybinding; diff --git a/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts b/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts index b7229db58ed7..6523569962ac 100644 --- a/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts +++ b/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts @@ -153,6 +153,7 @@ interface IHardwareCodeMapping { export class MacLinuxKeyboardMapper implements IKeyboardMapper { + private readonly _rawMappings: IMacLinuxKeyboardMapping; private readonly _OS: OperatingSystem; private readonly _codeInfo: IHardwareCodeMapping[]; private readonly _hwToKb: number[] = []; @@ -161,7 +162,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper { private readonly _kbToHw: number[][] = []; constructor(rawMappings: IMacLinuxKeyboardMapping, OS: OperatingSystem) { - + this._rawMappings = rawMappings; this._OS = OS; this._hwToKb = []; @@ -283,6 +284,10 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper { } } + public dumpRawDebugInfo(): string { + return JSON.stringify(this._rawMappings, null, '\t'); + } + public dumpDebugInfo(): string { let result: string[] = []; diff --git a/src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts b/src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts index c9afbcf8f342..d3fed23e6e15 100644 --- a/src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts +++ b/src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts @@ -177,12 +177,14 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding { export class WindowsKeyboardMapper implements IKeyboardMapper { + private readonly _rawMappings: IWindowsKeyboardMapping; private readonly _codeInfo: IHardwareCodeMapping[]; private readonly _hwToKb: KeyCode[]; private readonly _kbToLabel: string[] = []; private readonly _kbExists: boolean[]; constructor(rawMappings: IWindowsKeyboardMapping) { + this._rawMappings = rawMappings; this._hwToKb = []; this._kbToLabel = []; this._kbExists = []; @@ -241,6 +243,10 @@ export class WindowsKeyboardMapper implements IKeyboardMapper { } } + public dumpRawDebugInfo(): string { + return JSON.stringify(this._rawMappings, null, '\t'); + } + public dumpDebugInfo(): string { let result: string[] = []; diff --git a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts index 5aa0d290b44c..46d7974ce05a 100644 --- a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts +++ b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts @@ -186,6 +186,10 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService { }); } + public dumpDebugInfo(): string { + return this._keyboardMapper.dumpDebugInfo() + `\n\n\nraw info: \n` + this._keyboardMapper.dumpRawDebugInfo(); + } + private _safeGetConfig(): IUserFriendlyKeybinding[] { let rawConfig = this.userKeybindings.getConfig(); if (Array.isArray(rawConfig)) {