@@ -8,16 +8,19 @@ import { ConfigurationChangeEvent, Disposable, TextDocumentChangeEvent, TextEdit
88import { Control } from './control' ;
99import { UtilCommands } from './util/commands/common' ;
1010import { configuration } from './util/configuration/config' ;
11+ import { defaults } from './util/configuration/defaults' ;
1112import { Logger } from './util/logger' ;
1213import { StatusBar , StatusBarControl } from './util/statusBar' ;
1314
1415export const enum GCodeUnits {
1516 Inch = 'Inch' ,
1617 MM = 'Metric' ,
1718 Auto = 'Auto' ,
18- Default = 'Defautlt (Inch)' ,
19+ Default = 'Default (Inch)' ,
1920}
2021
22+ const cfgUnits = 'general.units' ;
23+
2124export class GCodeUnitsController implements Disposable {
2225 private readonly _disposable : Disposable | undefined ;
2326 private _editor : TextEditor | undefined ;
@@ -29,7 +32,7 @@ export class GCodeUnitsController implements Disposable {
2932 constructor ( ) {
3033 this . _statusbar = Control . statusBarController ;
3134
32- this . _auto = ( this . _units = < GCodeUnits > configuration . getParam ( ' general.units' ) ) === GCodeUnits . Auto ;
35+ this . _auto = ( this . _units = configuration . getParam ( cfgUnits ) ?? defaults . general . units ) === GCodeUnits . Auto ;
3336
3437 this . _statusbar . updateStatusBar (
3538 this . _units ,
@@ -49,8 +52,8 @@ export class GCodeUnitsController implements Disposable {
4952 }
5053
5154 private onConfigurationChanged ( e : ConfigurationChangeEvent ) {
52- if ( configuration . changed ( e , 'general.units' ) ) {
53- if ( ( this . _units = < GCodeUnits > configuration . getParam ( ' general.units' ) ) !== ' Auto' ) {
55+ if ( configuration . changed ( e , cfgUnits ) ) {
56+ if ( ( this . _units = configuration . getParam ( cfgUnits ) ?? defaults . general . units ) !== GCodeUnits . Auto ) {
5457 Logger . log ( `Units: ${ this . _units } ` ) ;
5558 this . _auto = false ;
5659 this . _statusbar . updateStatusBar (
0 commit comments