@@ -20,6 +20,13 @@ import { StateControl } from './util/stateControl';
2020import { CodesWebview } from './webviews/codesWebview' ;
2121import { MachineTypeControl } from './util/machineType' ;
2222import { GCodeHoverControl } from './hovers/gcodeHoverControl' ;
23+ import { defaults } from './util/configuration/defaults' ;
24+
25+ const cfgUnits = 'general.units' ;
26+ const cfgAutoRef = {
27+ navTree : 'views.navTree.autoRefresh' ,
28+ stats : 'views.stats.autoRefresh' ,
29+ } ;
2330
2431export class Control {
2532 private static _config : Config | undefined ;
@@ -72,7 +79,7 @@ export class Control {
7279 this . _config = config ;
7380
7481 // Load StatusBars
75- context . subscriptions . push ( ( this . _statusBarControl = new StatusBarControl ( this . _context ) ) ) ;
82+ context . subscriptions . push ( ( this . _statusBarControl = new StatusBarControl ( ) ) ) ;
7683
7784 // Load Machine Type
7885 context . subscriptions . push ( ( this . _machineTypeControl = new MachineTypeControl ( ) ) ) ;
@@ -84,7 +91,7 @@ export class Control {
8491 context . subscriptions . push ( ( this . _hoverController = new GCodeHoverControl ( ) ) ) ;
8592
8693 // Units
87- this . _units = < string > config . getParam ( ' general.units' ) ;
94+ this . _units = config . getParam ( cfgUnits ) ?? defaults . general . units ;
8895 Logger . log ( `Units: ${ this . _units } ` ) ;
8996 if ( this . _units === 'Auto' ) {
9097 // Load Units Monitor
@@ -93,8 +100,8 @@ export class Control {
93100 let disposable : Disposable ;
94101 // eslint-disable-next-line prefer-const
95102 disposable = configuration . onDidChange ( e => {
96- if ( configuration . changed ( e , 'general.units' ) ) {
97- this . _units = < string > configuration . getParam ( 'general.units' ) ;
103+ if ( configuration . changed ( e , cfgUnits ) ) {
104+ this . _units = < string > configuration . getParam ( cfgUnits ) ;
98105 if ( this . _units === 'Auto' ) {
99106 disposable . dispose ( ) ;
100107 Logger . log ( `Units: ${ this . _units } ` ) ;
@@ -114,14 +121,14 @@ export class Control {
114121 context . subscriptions . push ( ( this . _navTree = new NavTreeView ( ) ) ) ;
115122
116123 Logger . log (
117- `Nav Tree AutoRefresh: ${ configuration . getParam ( 'views .navTree.autoRefresh' ) ? 'Enabled' : 'Disabled' } ` ,
124+ `Nav Tree AutoRefresh: ${ configuration . getParam < boolean > ( cfgAutoRef . navTree ) ? 'Enabled' : 'Disabled' } ` ,
118125 ) ;
119126
120127 // Load Stats View
121128 Logger . log ( 'Loading Stats View...' ) ;
122129 context . subscriptions . push ( ( this . _statsView = new StatsView ( ) ) ) ;
123130
124- Logger . log ( `Stats AutoRefresh: ${ configuration . getParam ( 'views .stats.autoRefresh' ) ? 'Enabled' : 'Disabled' } ` ) ;
131+ Logger . log ( `Stats AutoRefresh: ${ configuration . getParam < boolean > ( cfgAutoRef . stats ) ? 'Enabled' : 'Disabled' } ` ) ;
125132
126133 // Load Support Heart to Statusbar
127134 this . _statusBarControl . updateStatusBar (
0 commit comments