Skip to content

Commit b8de058

Browse files
committed
Get back the link to open keybindings shortcut file
1 parent 00d8b55 commit b8de058

2 files changed

Lines changed: 23 additions & 17 deletions

File tree

src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { KeybindingsEditorInput } from 'vs/workbench/services/preferences/common
4545
import { CancellationToken } from 'vs/base/common/cancellation';
4646
import { attachStylerCallback } from 'vs/platform/theme/common/styler';
4747
import { IStorageService } from 'vs/platform/storage/common/storage';
48+
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
4849

4950
let $ = DOM.$;
5051

@@ -91,7 +92,8 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
9192
@IClipboardService private clipboardService: IClipboardService,
9293
@IInstantiationService private instantiationService: IInstantiationService,
9394
@IEditorService private editorService: IEditorService,
94-
@IStorageService storageService: IStorageService
95+
@IStorageService storageService: IStorageService,
96+
@IPreferencesService private preferencesService: IPreferencesService
9597
) {
9698
super(KeybindingsEditor.ID, telemetryService, themeService, storageService);
9799
this.delayedFiltering = new Delayer<void>(300);
@@ -346,6 +348,8 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
346348
}));
347349

348350
this.actionBar.push([this.recordKeysAction, this.sortByPrecedenceAction, clearInputAction], { label: false, icon: true });
351+
352+
this.createOpenKeybindingsElement(this.headerContainer);
349353
}
350354

351355
private createRecordingBadge(container: HTMLElement): HTMLElement {
@@ -365,6 +369,24 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
365369
return recordingBadge;
366370
}
367371

372+
private createOpenKeybindingsElement(parent: HTMLElement): void {
373+
const openKeybindingsContainer = DOM.append(parent, $('.open-keybindings-container'));
374+
DOM.append(openKeybindingsContainer, $('', null, localize('header-message', "For advanced customizations open and edit")));
375+
const fileElement = DOM.append(openKeybindingsContainer, $('.file-name', null, localize('keybindings-file-name', "keybindings.json")));
376+
fileElement.tabIndex = 0;
377+
this._register(DOM.addDisposableListener(fileElement, DOM.EventType.CLICK, () => this.preferencesService.openGlobalKeybindingSettings(true)));
378+
this._register(DOM.addDisposableListener(fileElement, DOM.EventType.KEY_UP, e => {
379+
let keyboardEvent = new StandardKeyboardEvent(e);
380+
switch (keyboardEvent.keyCode) {
381+
case KeyCode.Enter:
382+
this.preferencesService.openGlobalKeybindingSettings(true);
383+
keyboardEvent.preventDefault();
384+
keyboardEvent.stopPropagation();
385+
return;
386+
}
387+
}));
388+
}
389+
368390
private layoutSearchWidget(dimension: DOM.Dimension): void {
369391
this.searchWidget.layout(dimension);
370392
DOM.toggleClass(this.headerContainer, 'small', dimension.width < 400);

src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -386,22 +386,6 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
386386
}
387387
});
388388

389-
CommandsRegistry.registerCommand(OpenGlobalKeybindingsFileAction.ID, serviceAccessor => {
390-
serviceAccessor.get(IInstantiationService).createInstance(OpenGlobalKeybindingsFileAction, OpenGlobalKeybindingsFileAction.ID, OpenGlobalKeybindingsFileAction.LABEL).run();
391-
});
392-
MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
393-
command: {
394-
id: OpenGlobalKeybindingsFileAction.ID,
395-
title: OpenGlobalKeybindingsFileAction.LABEL,
396-
iconLocation: {
397-
light: URI.parse(require.toUrl(`vs/workbench/parts/preferences/browser/media/open-file.svg`)),
398-
dark: URI.parse(require.toUrl(`vs/workbench/parts/preferences/browser/media/open-file-inverse.svg`))
399-
}
400-
},
401-
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR),
402-
group: 'navigation',
403-
});
404-
405389
CommandsRegistry.registerCommand(KEYBINDINGS_EDITOR_SHOW_DEFAULT_KEYBINDINGS, serviceAccessor => {
406390
const control = serviceAccessor.get(IEditorService).activeControl as IKeybindingsEditor;
407391
if (control) {

0 commit comments

Comments
 (0)