@@ -42,22 +42,15 @@ export default class HarperPlugin extends Plugin {
4242 return ;
4343 }
4444
45- const data = await this . loadData ( ) ;
46-
4745 this . app . workspace . onLayoutReady ( async ( ) => {
4846 this . state = new State (
4947 ( n ) => this . saveData ( n ) ,
5048 ( ) => this . app . workspace . updateOptions ( ) ,
5149 editorInfoField ,
5250 ) ;
5351
54- await this . state . initializeFromSettings ( data ) ;
5552 this . registerEditorExtension ( this . state . getCMEditorExtensions ( ) ) ;
56- if ( ! ( data ?. lintEnabled ?? true ) ) {
57- this . state . disableEditorLinter ( false ) ;
58- } else this . state . enableEditorLinter ( false ) ;
59- this . settings ?. update ( ) ;
60-
53+ await this . reloadSettingsFromDisk ( ) ;
6154 this . setupStatusBar ( ) ;
6255 } ) ;
6356
@@ -67,6 +60,28 @@ export default class HarperPlugin extends Plugin {
6760 this . setupCommands ( ) ;
6861 }
6962
63+ async onExternalSettingsChange ( ) {
64+ await this . reloadSettingsFromDisk ( ) ;
65+ }
66+
67+ private async reloadSettingsFromDisk ( ) {
68+ const data = await this . loadData ( ) ;
69+ if ( this . state == null ) {
70+ return ;
71+ }
72+
73+ await this . state . initializeFromSettings ( data ) ;
74+
75+ if ( ! ( data ?. lintEnabled ?? true ) ) {
76+ this . state . disableEditorLinter ( false ) ;
77+ } else {
78+ this . state . enableEditorLinter ( false ) ;
79+ }
80+
81+ this . settings ?. update ( ) ;
82+ this . updateStatusBar ( data ?. dialect ?? Dialect . American ) ;
83+ }
84+
7085 private getDialectStatus ( dialectNum : Dialect ) : string {
7186 const code = {
7287 American : 'US' ,
0 commit comments