@@ -780,10 +780,10 @@ pub struct Config {
780
780
user_config : Option < ( GlobalLocalConfigInput , ConfigErrors ) > ,
781
781
782
782
/// TODO : This file can be used to make global changes while having only a workspace-wide scope.
783
- workspace_ratoml_change : FxHashMap < SourceRootId , ( GlobalLocalConfigInput , ConfigErrors ) > ,
783
+ workspace_ratoml : FxHashMap < SourceRootId , ( GlobalLocalConfigInput , ConfigErrors ) > ,
784
784
785
785
/// For every `SourceRoot` there can be at most one RATOML file.
786
- ratoml_files : FxHashMap < SourceRootId , ( LocalConfigInput , ConfigErrors ) > ,
786
+ krate_ratoml : FxHashMap < SourceRootId , ( LocalConfigInput , ConfigErrors ) > ,
787
787
788
788
/// Clone of the value that is stored inside a `GlobalState`.
789
789
source_root_parent_map : Arc < FxHashMap < SourceRootId , SourceRootId > > ,
@@ -927,7 +927,7 @@ impl Config {
927
927
& mut String :: new ( ) ,
928
928
& mut toml_errors,
929
929
) ;
930
- config. workspace_ratoml_change . insert (
930
+ config. workspace_ratoml . insert (
931
931
source_root_id,
932
932
(
933
933
GlobalLocalConfigInput :: from_toml ( table, & mut toml_errors) ,
@@ -969,7 +969,7 @@ impl Config {
969
969
& mut String :: new ( ) ,
970
970
& mut toml_errors,
971
971
) ;
972
- config. ratoml_files . insert (
972
+ config. krate_ratoml . insert (
973
973
source_root_id,
974
974
(
975
975
LocalConfigInput :: from_toml ( & table, & mut toml_errors) ,
@@ -1022,15 +1022,9 @@ impl Config {
1022
1022
. 1
1023
1023
. 0
1024
1024
. iter ( )
1025
- . chain (
1026
- config
1027
- . workspace_ratoml_change
1028
- . values ( )
1029
- . into_iter ( )
1030
- . flat_map ( |it| it. 1 . 0 . iter ( ) ) ,
1031
- )
1025
+ . chain ( config. workspace_ratoml . values ( ) . into_iter ( ) . flat_map ( |it| it. 1 . 0 . iter ( ) ) )
1032
1026
. chain ( config. user_config . as_ref ( ) . into_iter ( ) . flat_map ( |it| it. 1 . 0 . iter ( ) ) )
1033
- . chain ( config. ratoml_files . values ( ) . flat_map ( |it| it. 1 . 0 . iter ( ) ) )
1027
+ . chain ( config. krate_ratoml . values ( ) . flat_map ( |it| it. 1 . 0 . iter ( ) ) )
1034
1028
. chain ( config. validation_errors . 0 . iter ( ) )
1035
1029
. cloned ( )
1036
1030
. collect ( ) ,
@@ -1070,6 +1064,7 @@ impl ConfigChange {
1070
1064
vfs_path : VfsPath ,
1071
1065
content : Option < Arc < str > > ,
1072
1066
) -> Option < ( VfsPath , Option < Arc < str > > ) > {
1067
+ dbg ! ( "change_ratoml" , & vfs_path) ;
1073
1068
self . ratoml_file_change
1074
1069
. get_or_insert_with ( Default :: default)
1075
1070
. insert ( source_root, ( vfs_path, content) )
@@ -1086,6 +1081,7 @@ impl ConfigChange {
1086
1081
vfs_path : VfsPath ,
1087
1082
content : Option < Arc < str > > ,
1088
1083
) -> Option < ( VfsPath , Option < Arc < str > > ) > {
1084
+ dbg ! ( "change_workspace" , & vfs_path) ;
1089
1085
self . workspace_ratoml_change
1090
1086
. get_or_insert_with ( Default :: default)
1091
1087
. insert ( source_root, ( vfs_path, content) )
@@ -1350,14 +1346,14 @@ impl Config {
1350
1346
workspace_roots,
1351
1347
visual_studio_code_version,
1352
1348
client_config : ( FullConfigInput :: default ( ) , ConfigErrors ( vec ! [ ] ) ) ,
1353
- ratoml_files : FxHashMap :: default ( ) ,
1349
+ krate_ratoml : FxHashMap :: default ( ) ,
1354
1350
default_config : DEFAULT_CONFIG_DATA . get_or_init ( || Box :: leak ( Box :: default ( ) ) ) ,
1355
1351
source_root_parent_map : Arc :: new ( FxHashMap :: default ( ) ) ,
1356
1352
user_config : None ,
1357
1353
user_config_path,
1358
1354
detached_files : Default :: default ( ) ,
1359
1355
validation_errors : Default :: default ( ) ,
1360
- workspace_ratoml_change : Default :: default ( ) ,
1356
+ workspace_ratoml : Default :: default ( ) ,
1361
1357
}
1362
1358
}
1363
1359
@@ -1877,16 +1873,16 @@ impl Config {
1877
1873
}
1878
1874
}
1879
1875
1880
- pub fn rustfmt ( & self ) -> RustfmtConfig {
1876
+ pub fn rustfmt ( & self , source_root_id : Option < SourceRootId > ) -> RustfmtConfig {
1881
1877
match & self . rustfmt_overrideCommand ( None ) {
1882
1878
Some ( args) if !args. is_empty ( ) => {
1883
1879
let mut args = args. clone ( ) ;
1884
1880
let command = args. remove ( 0 ) ;
1885
1881
RustfmtConfig :: CustomCommand { command, args }
1886
1882
}
1887
1883
Some ( _) | None => RustfmtConfig :: Rustfmt {
1888
- extra_args : self . rustfmt_extraArgs ( None ) . clone ( ) ,
1889
- enable_range_formatting : * self . rustfmt_rangeFormatting_enable ( None ) ,
1884
+ extra_args : self . rustfmt_extraArgs ( source_root_id ) . clone ( ) ,
1885
+ enable_range_formatting : * self . rustfmt_rangeFormatting_enable ( source_root_id ) ,
1890
1886
} ,
1891
1887
}
1892
1888
}
@@ -2540,22 +2536,28 @@ macro_rules! _impl_for_config_data {
2540
2536
$( $doc) *
2541
2537
#[ allow( non_snake_case) ]
2542
2538
$vis fn $field( & self , source_root: Option <SourceRootId >) -> & $ty {
2543
- let mut par: Option <SourceRootId > = source_root;
2544
- while let Some ( source_root_id) = par {
2545
- par = self . source_root_parent_map. get( & source_root_id) . copied( ) ;
2546
- if let Some ( ( config, _) ) = self . ratoml_files. get( & source_root_id) {
2539
+ let follow = if stringify!( $field) == "assist_emitMustUse" { dbg!( "YEY" ) ; true } else { false } ;
2540
+ let mut current: Option <SourceRootId > = None ;
2541
+ let mut next: Option <SourceRootId > = source_root;
2542
+ if follow { dbg!( & self . krate_ratoml) ; }
2543
+ while let Some ( source_root_id) = next {
2544
+ current = next;
2545
+ next = self . source_root_parent_map. get( & source_root_id) . copied( ) ;
2546
+ if let Some ( ( config, _) ) = self . krate_ratoml. get( & source_root_id) {
2547
2547
if let Some ( value) = config. $field. as_ref( ) {
2548
2548
return value;
2549
2549
}
2550
2550
}
2551
2551
}
2552
2552
2553
- // TODO
2554
- // if let Some((root_path_ratoml, _)) = self.root_ratoml.as_ref() {
2555
- // if let Some(v) = root_path_ratoml.local.$field.as_ref() {
2556
- // return &v;
2557
- // }
2558
- // }
2553
+ if let Some ( current) = current {
2554
+ if follow { dbg!( & self . workspace_ratoml) ; }
2555
+ if let Some ( ( root_path_ratoml, _) ) = self . workspace_ratoml. get( & current) . as_ref( ) {
2556
+ if let Some ( v) = root_path_ratoml. local. $field. as_ref( ) {
2557
+ return & v;
2558
+ }
2559
+ }
2560
+ }
2559
2561
2560
2562
if let Some ( v) = self . client_config. 0 . local. $field. as_ref( ) {
2561
2563
return & v;
@@ -2582,12 +2584,22 @@ macro_rules! _impl_for_config_data {
2582
2584
$( $doc) *
2583
2585
#[ allow( non_snake_case) ]
2584
2586
$vis fn $field( & self , source_root : Option <SourceRootId >) -> & $ty {
2585
- // TODO
2586
- // if let Some((root_path_ratoml, _)) = self.root_ratoml.as_ref() {
2587
- // if let Some(v) = root_path_ratoml.global.$field.as_ref() {
2588
- // return &v;
2589
- // }
2590
- // }
2587
+ let follow = if stringify!( $field) == "rustfmt_extraArgs" { dbg!( "YEY" ) ; true } else { false } ;
2588
+ let mut current: Option <SourceRootId > = None ;
2589
+ let mut next: Option <SourceRootId > = source_root;
2590
+ while let Some ( source_root_id) = next {
2591
+ current = next;
2592
+ next = self . source_root_parent_map. get( & source_root_id) . copied( ) ;
2593
+ }
2594
+
2595
+ if let Some ( current) = current {
2596
+ if follow { dbg!( & self . workspace_ratoml) ; }
2597
+ if let Some ( ( root_path_ratoml, _) ) = self . workspace_ratoml. get( & current) . as_ref( ) {
2598
+ if let Some ( v) = root_path_ratoml. global. $field. as_ref( ) {
2599
+ return & v;
2600
+ }
2601
+ }
2602
+ }
2591
2603
2592
2604
if let Some ( v) = self . client_config. 0 . global. $field. as_ref( ) {
2593
2605
return & v;
0 commit comments