Skip to content

Commit

Permalink
fix: setting config not working when deleting property (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortalYoung authored Aug 5, 2021
1 parent 3370b0f commit 23116af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/controller/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import {
PanelService,
SettingsService,
} from 'mo/services';
import { SettingsEvent, BuiltInSettingsTab } from 'mo/model/settings';
import {
SettingsEvent,
BuiltInSettingsTab,
initialEditorSetting,
initialWorkbenchSetting,
} from 'mo/model/settings';

export interface ISettingsController {}

Expand Down Expand Up @@ -37,6 +42,11 @@ export class SettingsController
const config = this.settingsService.normalizeFlatObject(
tab.data?.value || ''
);
config.editor = { ...initialEditorSetting, ...config.editor };
config.workbench = {
...initialWorkbenchSetting,
...config.workbench,
};
this.settingsService.update(config);
}
});
Expand Down
8 changes: 4 additions & 4 deletions src/model/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export enum SettingsEvent {
OnChange = 'settings.onchange',
}

const initialWorkbenchSetting = {
export const initialWorkbenchSetting = {
colorTheme: 'Default Dark+',
};

const initialEditorSetting: IEditorSettings = {
export const initialEditorSetting: IEditorSettings = {
renderWhitespace: 'none',
tabSize: 4,
fontSize: 14,
Expand All @@ -47,8 +47,8 @@ export class SettingsModel implements ISettings {
editor: IEditorSettings;

constructor(
workbench: IWorkbenchSettings = initialWorkbenchSetting,
editor: IEditorSettings = initialEditorSetting
workbench: IWorkbenchSettings = { ...initialWorkbenchSetting },
editor: IEditorSettings = { ...initialEditorSetting }
) {
this.workbench = workbench;
this.editor = editor;
Expand Down

0 comments on commit 23116af

Please sign in to comment.