@@ -2537,30 +2537,27 @@ package body LSP.Ada_Handlers is
2537
2537
(Self : in out Message_Handler;
2538
2538
Value : LSP.Structures.InitializedParams) is
2539
2539
begin
2540
- -- The client is notifying us that it has initialized. If a project was
2541
- -- provided with the initialize request, we can load it and start
2542
- -- communicating with the client.
2540
+ -- The client is notifying us that it has initialized. It is good at
2541
+ -- this stage to load a project so that subsequent requests, e.g.
2542
+ -- project attribute requests to support VS Code integration, work on a
2543
+ -- valid project.
2543
2544
--
2544
- -- We only perform loading in case ada.projectFile was provided with the
2545
- -- initialize request. That's because some clients don't provide
2546
- -- settings in the initialize request, and instead send a
2547
- -- onDidChangeConfiguration notification immediately after
2548
- -- initialization. In this scenario, loading a project unconditionally
2549
- -- here would result in automatically searching for a project (unique
2550
- -- project at the root, or implicit fallback) and loading it, only to
2551
- -- load another project shortly after, upon receiving
2552
- -- onDidChangeConfiguration. To avoid the first useless load, we only
2553
- -- load a project here if it was specified in the initialize request.
2554
- --
2555
- -- Moreover, there is an impact on legacy tests. The prior project
2545
+ -- However, there is an impact on legacy tests. The prior project
2556
2546
-- loading policy was to wait for the first onDidChangeConfiguration
2557
2547
-- notification to obtain settings and load a project. Many existing
2558
2548
-- tests do not set the project in the initialize request and don't
2559
2549
-- expect messages pertaining to project loading after the initialize
2560
- -- request. If we were to always load the project here, tests would
2561
- -- receive different messages and potentially fail. So the conditional
2562
- -- project loading here is backwards compatible with existing tests.
2563
- if not Self.Configuration.Project_File.Is_Empty then
2550
+ -- request. If we were to always load the project here, tests would
2551
+ -- receive different messages and potentially fail.
2552
+ --
2553
+ -- To mitigate that, we perform project loading conditionally to
2554
+ -- Base_Configuration_Received. If Base_Configuration_Received is True,
2555
+ -- it means that we received non-empty initializationOptions which is
2556
+ -- the typical case in IDEs like GNAT Studio and VS Code.
2557
+ --
2558
+ -- This conditional load allows us to load a project early while
2559
+ -- remaining backwards compatible with legacy tests.
2560
+ if Self.Base_Configuration_Received then
2564
2561
LSP.Ada_Handlers.Project_Loading.Ensure_Project_Loaded (Self);
2565
2562
end if ;
2566
2563
end On_Initialized_Notification ;
0 commit comments