@@ -438,6 +438,8 @@ package body LSP.Ada_Handlers is
438
438
To_Virtual_String (ALS_Workspace_Config_File),
439
439
To_Virtual_String (CLI_Config_File)];
440
440
441
+ Config_File_Processed : Boolean := False;
442
+ New_Configuration : LSP.Ada_Configurations.Configuration;
441
443
begin
442
444
for F_Path of Candidates loop
443
445
if not F_Path.Is_Empty then
@@ -448,7 +450,8 @@ package body LSP.Ada_Handlers is
448
450
Self.Tracer.Trace_Text (" Trying config file: " & F_Path);
449
451
if F.Is_Regular_File then
450
452
Self.Tracer.Trace_Text (" Loading config file: " & F_Path);
451
- Self.Configuration.Read_File (F_Path);
453
+ New_Configuration.Read_File (F_Path);
454
+ Config_File_Processed := True;
452
455
else
453
456
Self.Tracer.Trace_Text (F_Path & " doesn't exist" );
454
457
end if ;
@@ -461,16 +464,20 @@ package body LSP.Ada_Handlers is
461
464
-- overwritten if a value is provided in the initialize request.
462
465
-- Prioritize the config file given on the CLI.
463
466
if CLI_Config_File.Is_Regular_File then
464
- Self.Client.Set_Root_If_Empty (To_Virtual_String (CLI_Config_File.Dir));
467
+ Self.Client.Set_Root_If_Empty
468
+ (To_Virtual_String (CLI_Config_File.Dir));
465
469
elsif ALS_Workspace_Config_File.Is_Regular_File then
466
- Self.Client.Set_Root_If_Empty (
467
- To_Virtual_String (ALS_Workspace_Config_File.Get_Parent));
470
+ Self.Client.Set_Root_If_Empty
471
+ ( To_Virtual_String (ALS_Workspace_Config_File.Get_Parent));
468
472
end if ;
469
473
470
- -- Save the initial configuration so that we can restore individual
471
- -- settings back to the initial state when 'onDidChangeConfiguration'
472
- -- provides null values.
473
- Self.Base_Configuration := Self.Configuration;
474
+ -- Set it as the current configuration.
475
+ -- This will also save it as the initial configuration so that
476
+ -- we can restore individual settings back to the initial state when
477
+ -- 'onDidChangeConfiguration' provides null values.
478
+ if Config_File_Processed then
479
+ Self.Set_Configuration (New_Configuration);
480
+ end if ;
474
481
end Load_Config_Files ;
475
482
476
483
-- -----------------
@@ -2425,7 +2432,19 @@ package body LSP.Ada_Handlers is
2425
2432
-- ...
2426
2433
-- }
2427
2434
-- }
2428
- Self.Configuration.Read_JSON (Value.initializationOptions);
2435
+ declare
2436
+ New_Configuration : LSP.Ada_Configurations.Configuration;
2437
+ begin
2438
+ -- Parse the configuration.
2439
+ New_Configuration.Read_JSON (Value.initializationOptions);
2440
+
2441
+ -- Set it as the current configuration.
2442
+ -- This will also save it as the initial configuration (if not done
2443
+ -- yet through config files) so that we can restore individual
2444
+ -- settings back to the initial state when
2445
+ -- 'onDidChangeConfiguration' provides null values.
2446
+ Self.Set_Configuration (New_Configuration);
2447
+ end ;
2429
2448
2430
2449
-- We don't load the project here because we can't send progress
2431
2450
-- notifications to the client before receiving the 'initialized'
@@ -3783,6 +3802,14 @@ package body LSP.Ada_Handlers is
3783
3802
Value : LSP.Ada_Configurations.Configuration'Class) is
3784
3803
begin
3785
3804
Self.Configuration := LSP.Ada_Configurations.Configuration (Value);
3805
+
3806
+ -- The base configuration is still the default one, meaning that
3807
+ -- we did not receive any user configuration previously: use
3808
+ -- the new configuration as the base one.
3809
+ if not Self.Base_Configuration_Received then
3810
+ Self.Base_Configuration := Self.Configuration;
3811
+ Self.Base_Configuration_Received := True;
3812
+ end if ;
3786
3813
end Set_Configuration ;
3787
3814
3788
3815
-- ---------------------
0 commit comments