Skip to content

Commit

Permalink
feat: add the quickAccess for the Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
wewoor committed May 26, 2021
1 parent 223ea3c commit 458a4ca
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/monaco/quickAccessSettingsAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import 'reflect-metadata';
import { localize } from 'monaco-editor/esm/vs/nls';
import { KeyMod, KeyCode } from 'mo/monaco';
import { KeyChord } from 'monaco-editor/esm/vs/base/common/keyCodes';
import { ISettingsService, SettingsService } from 'mo/services';
import { ServicesAccessor } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation';
import { container } from 'tsyringe';
import { Action2, KeybindingWeight } from './common';

export class QuickAccessSettings extends Action2 {
static readonly ID = 'workbench.action.quickAccessSettings';
static readonly LABEL = localize(
'quickAccessSettings.label',
'Open Settings (JSON)'
);
private readonly settingsService: ISettingsService;

constructor() {
super({
id: QuickAccessSettings.ID,
label: QuickAccessSettings.LABEL,
title: QuickAccessSettings.LABEL,
alias: 'Open Settings (JSON)',
precondition: undefined,
f1: true,
keybinding: {
when: undefined,
weight: KeybindingWeight.WorkbenchContrib,
// eslint-disable-next-line new-cap
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.US_COMMA),
},
});
this.settingsService = container.resolve(SettingsService);
}

run(accessor: ServicesAccessor) {
this.settingsService.openSettingsInEditor();
}
}
2 changes: 2 additions & 0 deletions src/provider/molecule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ID_APP } from 'mo/common/id';
import { IMonacoService, MonacoService } from 'mo/monaco/monacoService';
import { CommandQuickAccessViewAction } from 'mo/monaco/quickAccessViewAction';
import { registerAction2 } from 'mo/monaco/common';
import { QuickAccessSettings } from 'mo/monaco/quickAccessSettingsAction';
import { SelectColorThemeAction } from 'mo/monaco/selectColorThemeAction';

export interface IMoleculeProps {
Expand Down Expand Up @@ -54,6 +55,7 @@ export class MoleculeProvider extends React.Component<IMoleculeProps> {
);
registerAction2(CommandQuickAccessViewAction);
registerAction2(SelectColorThemeAction);
registerAction2(QuickAccessSettings);
}

public render() {
Expand Down

0 comments on commit 458a4ca

Please sign in to comment.