@@ -505,10 +505,15 @@ class Server(config: EffektConfig, compileOnChange: Boolean=false) extends Langu
505
505
// nested under an "effekt" key `{ "effekt": { "showIR": "core", ... } }`
506
506
// The former is sent by the VSCode extension for `initializationOptions`,
507
507
// the latter by newer extension versions for `workspace/didChangeConfiguration`.
508
- val newSettings = params.getSettings.asInstanceOf [JsonElement ].getAsJsonObject
509
- this .settings = newSettings;
510
- if (newSettings == null ) return
511
- val effektSection = newSettings.get(" effekt" )
508
+ val newSettings = params.getSettings.asInstanceOf [JsonElement ]
509
+ // When the settings come via `initializationOptions`, they can be null as per the LSP spec.
510
+ if (newSettings.isJsonNull) {
511
+ this .settings = null ;
512
+ return ;
513
+ }
514
+ val newSettingsObj = newSettings.getAsJsonObject
515
+ this .settings = newSettingsObj;
516
+ val effektSection = newSettingsObj.get(" effekt" )
512
517
if (effektSection != null ) {
513
518
this .settings = effektSection
514
519
}
@@ -521,18 +526,16 @@ class Server(config: EffektConfig, compileOnChange: Boolean=false) extends Langu
521
526
//
522
527
523
528
def settingBool (name : String ): Boolean = {
524
- if (settings == null ) return false
529
+ if (settings == null || settings.isJsonNull ) return false
525
530
val obj = settings.getAsJsonObject
526
- if (obj == null ) return false
527
531
val value = obj.get(name)
528
532
if (value == null ) return false
529
533
value.getAsBoolean
530
534
}
531
535
532
536
def settingString (name : String ): Option [String ] = {
533
- if (settings == null ) return None
537
+ if (settings == null || settings.isJsonNull ) return None
534
538
val obj = settings.getAsJsonObject
535
- if (obj == null ) return None
536
539
val value = obj.get(name)
537
540
if (value == null ) return None
538
541
Some (value.getAsString)
0 commit comments