@@ -3,6 +3,7 @@ use crate::diagnostics::LspError;
33use crate :: documents:: Document ;
44use crate :: utils;
55use anyhow:: Result ;
6+ use biome_deserialize:: Merge ;
67use futures:: StreamExt ;
78use futures:: stream:: FuturesUnordered ;
89use pgt_analyse:: RuleCategoriesBuilder ;
@@ -386,11 +387,13 @@ impl Session {
386387 /// This function attempts to read the `postgrestools.jsonc` configuration file from
387388 /// the root URI and update the workspace settings accordingly
388389 #[ tracing:: instrument( level = "trace" , skip( self ) ) ]
389- pub ( crate ) async fn load_workspace_settings ( & self , params : Option < PartialConfiguration > ) {
390+ pub ( crate ) async fn load_workspace_settings ( & self , extra_config : Option < PartialConfiguration > ) {
390391 // Providing a custom configuration path will not allow to support workspaces
391392 if let Some ( config_path) = & self . config_path {
392393 let base_path = ConfigurationPathHint :: FromUser ( config_path. clone ( ) ) ;
393- let status = self . load_pgt_configuration_file ( base_path, params) . await ;
394+ let status = self
395+ . load_pgt_configuration_file ( base_path, extra_config)
396+ . await ;
394397 self . set_configuration_status ( status) ;
395398 } else if let Some ( folders) = self . get_workspace_folders ( ) {
396399 info ! ( "Detected workspace folder." ) ;
@@ -403,7 +406,7 @@ impl Session {
403406 let status = self
404407 . load_pgt_configuration_file (
405408 ConfigurationPathHint :: FromWorkspace ( base_path) ,
406- params . clone ( ) ,
409+ extra_config . clone ( ) ,
407410 )
408411 . await ;
409412 self . set_configuration_status ( status) ;
@@ -421,7 +424,9 @@ impl Session {
421424 None => ConfigurationPathHint :: default ( ) ,
422425 Some ( path) => ConfigurationPathHint :: FromLsp ( path) ,
423426 } ;
424- let status = self . load_pgt_configuration_file ( base_path, params) . await ;
427+ let status = self
428+ . load_pgt_configuration_file ( base_path, extra_config)
429+ . await ;
425430 self . set_configuration_status ( status) ;
426431 }
427432 }
@@ -434,24 +439,25 @@ impl Session {
434439 match load_configuration ( & self . fs , base_path. clone ( ) ) {
435440 Ok ( loaded_configuration) => {
436441 let LoadedConfiguration {
437- configuration : fs_configuration,
442+ configuration : mut fs_configuration,
438443 directory_path : configuration_path,
439444 ..
440445 } = loaded_configuration;
441446 info ! ( "Configuration loaded successfully from disk." ) ;
442447 info ! ( "Update workspace settings." ) ;
443448
449+ if let Some ( ws_configuration) = extra_config {
450+ fs_configuration. merge_with ( ws_configuration) ;
451+ }
452+
444453 let result = fs_configuration
445454 . retrieve_gitignore_matches ( & self . fs , configuration_path. as_deref ( ) ) ;
446455
447456 match result {
448457 Ok ( ( vcs_base_path, gitignore_matches) ) => {
449458 let result = self . workspace . update_settings ( UpdateSettingsParams {
450459 workspace_directory : self . fs . working_directory ( ) ,
451- configuration : match extra_config {
452- Some ( config) => fs_configuration. clone ( ) . merge ( config) ,
453- None => fs_configuration,
454- } ,
460+ configuration : fs_configuration,
455461 vcs_base_path,
456462 gitignore_matches,
457463 } ) ;
0 commit comments