Skip to content

Commit d4c2ccd

Browse files
authored
Merge pull request microsoft#53503 from njkevlani/feature-#53372
Fixes microsoft#53372
2 parents 5c82fed + 26edb37 commit d4c2ccd

5 files changed

Lines changed: 44 additions & 8 deletions

File tree

src/vs/workbench/electron-browser/main.contribution.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,11 @@ configurationRegistry.registerConfiguration({
425425
'description': nls.localize('openDefaultSettings', "Controls if opening settings also opens an editor showing all default settings."),
426426
'default': true
427427
},
428+
'workbench.settings.openDefaultKeybindings': {
429+
'type': 'boolean',
430+
'description': nls.localize('openDefaultKeybindings', "Controls if opening keybinding settings also opens an editor showing all default keybindings."),
431+
'default': true
432+
},
428433
'workbench.sideBar.location': {
429434
'type': 'string',
430435
'enum': ['left', 'right'],

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,24 @@ export class OpenGlobalKeybindingsFileAction extends Action {
125125
}
126126
}
127127

128+
export class OpenRawDefaultKeybindingsAction extends Action {
129+
130+
public static readonly ID = 'workbench.action.openRawDefaultKeybindings';
131+
public static readonly LABEL = nls.localize('openRawDefaultKeybindings', "Open Default Keyboard Shortcuts File");
132+
133+
constructor(
134+
id: string,
135+
label: string,
136+
@IPreferencesService private preferencesService: IPreferencesService
137+
) {
138+
super(id, label);
139+
}
140+
141+
public run(event?: any): TPromise<any> {
142+
return this.preferencesService.openRawDefaultKeybindings();
143+
}
144+
}
145+
128146
export class OpenWorkspaceSettingsAction extends Action {
129147

130148
public static readonly ID = 'workbench.action.openWorkspaceSettings';

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { PreferencesEditor } from 'vs/workbench/parts/preferences/browser/prefer
1919
import { SettingsEditor2 } from 'vs/workbench/parts/preferences/browser/settingsEditor2';
2020
import { DefaultPreferencesEditorInput, PreferencesEditorInput, KeybindingsEditorInput, SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput';
2121
import { KeybindingsEditor } from 'vs/workbench/parts/preferences/browser/keybindingsEditor';
22-
import { OpenRawDefaultSettingsAction, OpenSettingsAction, OpenGlobalSettingsAction, OpenGlobalKeybindingsFileAction, OpenWorkspaceSettingsAction, OpenFolderSettingsAction, ConfigureLanguageBasedSettingsAction, OPEN_FOLDER_SETTINGS_COMMAND, OpenGlobalKeybindingsAction, OpenSettings2Action } from 'vs/workbench/parts/preferences/browser/preferencesActions';
22+
import { OpenRawDefaultKeybindingsAction, OpenRawDefaultSettingsAction, OpenSettingsAction, OpenGlobalSettingsAction, OpenGlobalKeybindingsFileAction, OpenWorkspaceSettingsAction, OpenFolderSettingsAction, ConfigureLanguageBasedSettingsAction, OPEN_FOLDER_SETTINGS_COMMAND, OpenGlobalKeybindingsAction, OpenSettings2Action } from 'vs/workbench/parts/preferences/browser/preferencesActions';
2323
import {
2424
IKeybindingsEditor, IPreferencesSearchService, CONTEXT_KEYBINDING_FOCUS, CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS, KEYBINDINGS_EDITOR_COMMAND_DEFINE, KEYBINDINGS_EDITOR_COMMAND_REMOVE, KEYBINDINGS_EDITOR_COMMAND_SEARCH,
2525
KEYBINDINGS_EDITOR_COMMAND_COPY, KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND, KEYBINDINGS_EDITOR_COMMAND_SHOW_SIMILAR, KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS, KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, SETTINGS_EDITOR_COMMAND_SEARCH, CONTEXT_SETTINGS_EDITOR, SETTINGS_EDITOR_COMMAND_FOCUS_FILE, CONTEXT_SETTINGS_SEARCH_FOCUS, SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, SETTINGS_EDITOR_COMMAND_FOCUS_NEXT_SETTING, SETTINGS_EDITOR_COMMAND_FOCUS_PREVIOUS_SETTING, SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING, SETTINGS_EDITOR_COMMAND_FOCUS_SEARCH_FROM_SETTINGS, SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_FROM_SEARCH, CONTEXT_SETTINGS_FIRST_ROW_FOCUS, CONTEXT_SETTINGS_ROW_FOCUS, CONTEXT_TOC_ROW_FOCUS, SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_LIST
@@ -195,6 +195,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(OpenSettingsAction, Op
195195
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenSettings2Action, OpenSettings2Action.ID, OpenSettings2Action.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.US_COMMA }), 'Preferences: Open Settings (Preview)', category);
196196
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenGlobalSettingsAction, OpenGlobalSettingsAction.ID, OpenGlobalSettingsAction.LABEL), 'Preferences: Open User Settings', category);
197197
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenGlobalKeybindingsAction, OpenGlobalKeybindingsAction.ID, OpenGlobalKeybindingsAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_S) }), 'Preferences: Open Keyboard Shortcuts', category);
198+
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenRawDefaultKeybindingsAction, OpenRawDefaultKeybindingsAction.ID, OpenRawDefaultKeybindingsAction.LABEL), 'Preferences: Open Raw Default Settings', category);
198199
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenGlobalKeybindingsFileAction, OpenGlobalKeybindingsFileAction.ID, OpenGlobalKeybindingsFileAction.LABEL, { primary: null }), 'Preferences: Open Keyboard Shortcuts File', category);
199200
registry.registerWorkbenchAction(new SyncActionDescriptor(ConfigureLanguageBasedSettingsAction, ConfigureLanguageBasedSettingsAction.ID, ConfigureLanguageBasedSettingsAction.LABEL), 'Preferences: Configure Language Specific Settings...', category);
200201

src/vs/workbench/services/preferences/browser/preferencesService.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,21 +221,32 @@ export class PreferencesService extends Disposable implements IPreferencesServic
221221
if (textual) {
222222
const emptyContents = '// ' + nls.localize('emptyKeybindingsHeader', "Place your key bindings in this file to overwrite the defaults") + '\n[\n]';
223223
const editableKeybindings = URI.file(this.environmentService.appKeybindingsPath);
224+
const openDefaultKeybindings = !!this.configurationService.getValue('workbench.settings.openDefaultKeybindings');
224225

225226
// Create as needed and open in editor
227+
if (openDefaultKeybindings) {
228+
return this.createIfNotExists(editableKeybindings, emptyContents).then(() => {
229+
const activeEditorGroup = this.editorGroupService.activeGroup;
230+
const sideEditorGroup = this.editorGroupService.addGroup(activeEditorGroup.id, GroupDirection.RIGHT);
231+
232+
return TPromise.join([
233+
this.editorService.openEditor({ resource: this.defaultKeybindingsResource, options: { pinned: true, preserveFocus: true }, label: nls.localize('defaultKeybindings', "Default Keybindings"), description: '' }),
234+
this.editorService.openEditor({ resource: editableKeybindings, options: { pinned: true } }, sideEditorGroup.id)
235+
]).then(editors => void 0);
236+
});
237+
}
226238
return this.createIfNotExists(editableKeybindings, emptyContents).then(() => {
227-
const activeEditorGroup = this.editorGroupService.activeGroup;
228-
const sideEditorGroup = this.editorGroupService.addGroup(activeEditorGroup.id, GroupDirection.RIGHT);
229-
230-
return TPromise.join([
231-
this.editorService.openEditor({ resource: this.defaultKeybindingsResource, options: { pinned: true, preserveFocus: true }, label: nls.localize('defaultKeybindings', "Default Keybindings"), description: '' }),
232-
this.editorService.openEditor({ resource: editableKeybindings, options: { pinned: true } }, sideEditorGroup.id)
233-
]).then(editors => void 0);
239+
return this.editorService.openEditor({ resource: editableKeybindings, options: { pinned: true } }).then(editors => void 0);
234240
});
235241
}
242+
236243
return this.editorService.openEditor(this.instantiationService.createInstance(KeybindingsEditorInput), { pinned: true }).then(() => null);
237244
}
238245

246+
openRawDefaultKeybindings(): TPromise<IEditor> {
247+
return this.editorService.openEditor({ resource: this.defaultKeybindingsResource });
248+
}
249+
239250
configureSettingsForLanguage(language: string): void {
240251
this.openGlobalSettings()
241252
.then(editor => this.createPreferencesEditorModel(this.userSettingsResource)

src/vs/workbench/services/preferences/common/preferences.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export interface IPreferencesService {
152152
openFolderSettings(folder: URI, options?: IEditorOptions, group?: IEditorGroup): TPromise<IEditor>;
153153
switchSettings(target: ConfigurationTarget, resource: URI): TPromise<void>;
154154
openGlobalKeybindingSettings(textual: boolean): TPromise<void>;
155+
openRawDefaultKeybindings(): TPromise<IEditor>;
155156

156157
configureSettingsForLanguage(language: string): void;
157158
}

0 commit comments

Comments
 (0)