@@ -250,7 +250,9 @@ export class SettingsManager {
250250 private storage : SettingsStorage ;
251251 private globalSettings : Settings ;
252252 private projectSettings : Settings ;
253- private settings : Settings ;
253+ private settings : Settings = { } ;
254+ // Non-persisted overrides layered above global/project settings for this manager.
255+ private runtimeOverrides : Settings = { } ;
254256 private modifiedFields = new Set < keyof Settings > ( ) ; // Track global fields modified during session
255257 private modifiedNestedFields = new Map < keyof Settings , Set < string > > ( ) ; // Track global nested field modifications
256258 private modifiedProjectFields = new Set < keyof Settings > ( ) ; // Track project fields modified during session
@@ -274,7 +276,7 @@ export class SettingsManager {
274276 this . globalSettingsLoadError = globalLoadError ;
275277 this . projectSettingsLoadError = projectLoadError ;
276278 this . errors = [ ...initialErrors ] ;
277- this . settings = deepMergeSettings ( this . globalSettings , this . projectSettings ) ;
279+ this . recomputeSettings ( ) ;
278280 }
279281
280282 /** Create a SettingsManager that loads from files */
@@ -417,6 +419,13 @@ export class SettingsManager {
417419 return structuredClone ( this . projectSettings ) ;
418420 }
419421
422+ private recomputeSettings ( ) : void {
423+ this . settings = deepMergeSettings (
424+ deepMergeSettings ( this . globalSettings , this . projectSettings ) ,
425+ this . runtimeOverrides ,
426+ ) ;
427+ }
428+
420429 async reload ( ) : Promise < void > {
421430 await this . writeQueue ;
422431 const globalLoad = SettingsManager . tryLoadFromStorage ( this . storage , "global" ) ;
@@ -442,12 +451,13 @@ export class SettingsManager {
442451 this . recordError ( "project" , projectLoad . error ) ;
443452 }
444453
445- this . settings = deepMergeSettings ( this . globalSettings , this . projectSettings ) ;
454+ this . recomputeSettings ( ) ;
446455 }
447456
448- /** Apply additional overrides on top of current settings */
457+ /** Apply non-persisted overrides on top of global/project settings. */
449458 applyOverrides ( overrides : Partial < Settings > ) : void {
450- this . settings = deepMergeSettings ( this . settings , overrides ) ;
459+ this . runtimeOverrides = deepMergeSettings ( this . runtimeOverrides , overrides ) ;
460+ this . recomputeSettings ( ) ;
451461 }
452462
453463 /** Mark a global field as modified during this session */
@@ -541,7 +551,7 @@ export class SettingsManager {
541551 }
542552
543553 private save ( ) : void {
544- this . settings = deepMergeSettings ( this . globalSettings , this . projectSettings ) ;
554+ this . recomputeSettings ( ) ;
545555
546556 if ( this . globalSettingsLoadError ) {
547557 return ;
@@ -563,7 +573,7 @@ export class SettingsManager {
563573
564574 private saveProjectSettings ( settings : Settings ) : void {
565575 this . projectSettings = structuredClone ( settings ) ;
566- this . settings = deepMergeSettings ( this . globalSettings , this . projectSettings ) ;
576+ this . recomputeSettings ( ) ;
567577
568578 if ( this . projectSettingsLoadError ) {
569579 return ;
0 commit comments