@@ -3,6 +3,7 @@ use crate::diagnostics::LspError;
3
3
use crate :: documents:: Document ;
4
4
use crate :: utils;
5
5
use anyhow:: Result ;
6
+ use biome_deserialize:: Merge ;
6
7
use futures:: StreamExt ;
7
8
use futures:: stream:: FuturesUnordered ;
8
9
use pgt_analyse:: RuleCategoriesBuilder ;
@@ -386,11 +387,13 @@ impl Session {
386
387
/// This function attempts to read the `postgrestools.jsonc` configuration file from
387
388
/// the root URI and update the workspace settings accordingly
388
389
#[ 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 > ) {
390
391
// Providing a custom configuration path will not allow to support workspaces
391
392
if let Some ( config_path) = & self . config_path {
392
393
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 ;
394
397
self . set_configuration_status ( status) ;
395
398
} else if let Some ( folders) = self . get_workspace_folders ( ) {
396
399
info ! ( "Detected workspace folder." ) ;
@@ -403,7 +406,7 @@ impl Session {
403
406
let status = self
404
407
. load_pgt_configuration_file (
405
408
ConfigurationPathHint :: FromWorkspace ( base_path) ,
406
- params . clone ( ) ,
409
+ extra_config . clone ( ) ,
407
410
)
408
411
. await ;
409
412
self . set_configuration_status ( status) ;
@@ -421,7 +424,9 @@ impl Session {
421
424
None => ConfigurationPathHint :: default ( ) ,
422
425
Some ( path) => ConfigurationPathHint :: FromLsp ( path) ,
423
426
} ;
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 ;
425
430
self . set_configuration_status ( status) ;
426
431
}
427
432
}
@@ -434,24 +439,25 @@ impl Session {
434
439
match load_configuration ( & self . fs , base_path. clone ( ) ) {
435
440
Ok ( loaded_configuration) => {
436
441
let LoadedConfiguration {
437
- configuration : fs_configuration,
442
+ configuration : mut fs_configuration,
438
443
directory_path : configuration_path,
439
444
..
440
445
} = loaded_configuration;
441
446
info ! ( "Configuration loaded successfully from disk." ) ;
442
447
info ! ( "Update workspace settings." ) ;
443
448
449
+ if let Some ( ws_configuration) = extra_config {
450
+ fs_configuration. merge_with ( ws_configuration) ;
451
+ }
452
+
444
453
let result = fs_configuration
445
454
. retrieve_gitignore_matches ( & self . fs , configuration_path. as_deref ( ) ) ;
446
455
447
456
match result {
448
457
Ok ( ( vcs_base_path, gitignore_matches) ) => {
449
458
let result = self . workspace . update_settings ( UpdateSettingsParams {
450
459
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,
455
461
vcs_base_path,
456
462
gitignore_matches,
457
463
skip_db : false ,
0 commit comments