Skip to content

Commit 7396cb1

Browse files
committed
Have the Toggle Keyboard Shortcuts Troubleshooting action open the renderer log
1 parent e952b9c commit 7396cb1

4 files changed

Lines changed: 43 additions & 22 deletions

File tree

build/lib/i18n.resources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
"name": "vs/workbench/contrib/issue",
9595
"project": "vscode-workbench"
9696
},
97+
{
98+
"name": "vs/workbench/contrib/keybindings",
99+
"project": "vscode-workbench"
100+
},
97101
{
98102
"name": "vs/workbench/contrib/markers",
99103
"project": "vscode-workbench"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as nls from 'vs/nls';
7+
import { Action2, registerAction2 } from 'vs/platform/actions/common/actions';
8+
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
9+
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
10+
import { rendererLogChannelId } from 'vs/workbench/contrib/logs/common/logConstants';
11+
import { IOutputService } from 'vs/workbench/contrib/output/common/output';
12+
13+
const developerCategory = { value: nls.localize({ key: 'developer', comment: ['A developer on Code itself or someone diagnosing issues in Code'] }, "Developer"), original: 'Developer' };
14+
15+
class ToggleKeybindingsLogAction extends Action2 {
16+
17+
constructor() {
18+
super({
19+
id: 'workbench.action.toggleKeybindingsLog',
20+
title: { value: nls.localize('toggleKeybindingsLog', "Toggle Keyboard Shortcuts Troubleshooting"), original: 'Toggle Keyboard Shortcuts Troubleshooting' },
21+
category: developerCategory,
22+
f1: true
23+
});
24+
}
25+
26+
run(accessor: ServicesAccessor): void {
27+
const logging = accessor.get(IKeybindingService).toggleLogging();
28+
if (logging) {
29+
const outputService = accessor.get(IOutputService);
30+
outputService.showChannel(rendererLogChannelId);
31+
}
32+
}
33+
}
34+
35+
registerAction2(ToggleKeybindingsLogAction);

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { IUserKeybindingItem, KeybindingIO, OutputBuilder } from 'vs/workbench/s
3131
import { IKeyboardMapper } from 'vs/workbench/services/keybinding/common/keyboardMapper';
3232
import { IHostService } from 'vs/workbench/services/host/browser/host';
3333
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
34-
import { Action2, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions';
34+
import { MenuRegistry } from 'vs/platform/actions/common/actions';
3535
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
3636
import { commandsExtensionPoint } from 'vs/workbench/api/common/menusExtensionPoint';
3737
import { Disposable } from 'vs/base/common/lifecycle';
@@ -48,7 +48,6 @@ import { ScanCode, ScanCodeUtils, IMMUTABLE_CODE_TO_KEY_CODE } from 'vs/base/com
4848
import { flatten } from 'vs/base/common/arrays';
4949
import { BrowserFeatures, KeyboardSupport } from 'vs/base/browser/canIUse';
5050
import { ILogService } from 'vs/platform/log/common/log';
51-
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
5251
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
5352

5453
interface ContributedKeyBinding {
@@ -745,26 +744,6 @@ let schema: IJSONSchema = {
745744
}
746745
};
747746

748-
const preferencesCategory = nls.localize('preferences', "Preferences");
749-
750-
class ToggleKeybindingsLogAction extends Action2 {
751-
752-
constructor() {
753-
super({
754-
id: 'workbench.action.toggleKeybindingsLog',
755-
title: { value: nls.localize('toggleKeybindingsLog', "Toggle Keyboard Shortcuts Troubleshooting"), original: 'Toggle Keyboard Shortcuts Troubleshooting' },
756-
category: preferencesCategory,
757-
f1: true
758-
});
759-
}
760-
761-
run(accessor: ServicesAccessor): void {
762-
accessor.get(IKeybindingService).toggleLogging();
763-
}
764-
}
765-
766-
registerAction2(ToggleKeybindingsLogAction);
767-
768747
let schemaRegistry = Registry.as<IJSONContributionRegistry>(Extensions.JSONContribution);
769748
schemaRegistry.registerSchema(schemaId, schema);
770749

src/vs/workbench/workbench.common.main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ import 'vs/workbench/contrib/emmet/browser/emmet.contribution';
232232
// CodeEditor Contributions
233233
import 'vs/workbench/contrib/codeEditor/browser/codeEditor.contribution';
234234

235+
// Keybindings Contributions
236+
import 'vs/workbench/contrib/keybindings/browser/keybindings.contribution';
237+
235238
// Execution
236239
import 'vs/workbench/contrib/externalTerminal/browser/externalTerminal.contribution';
237240

0 commit comments

Comments
 (0)