@@ -780,10 +780,10 @@ pub struct Config {
780780 user_config : Option < ( GlobalLocalConfigInput , ConfigErrors ) > ,
781781
782782 /// 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 ) > ,
784784
785785 /// 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 ) > ,
787787
788788 /// Clone of the value that is stored inside a `GlobalState`.
789789 source_root_parent_map : Arc < FxHashMap < SourceRootId , SourceRootId > > ,
@@ -927,7 +927,7 @@ impl Config {
927927 & mut String :: new ( ) ,
928928 & mut toml_errors,
929929 ) ;
930- config. workspace_ratoml_change . insert (
930+ config. workspace_ratoml . insert (
931931 source_root_id,
932932 (
933933 GlobalLocalConfigInput :: from_toml ( table, & mut toml_errors) ,
@@ -969,7 +969,7 @@ impl Config {
969969 & mut String :: new ( ) ,
970970 & mut toml_errors,
971971 ) ;
972- config. ratoml_files . insert (
972+ config. krate_ratoml . insert (
973973 source_root_id,
974974 (
975975 LocalConfigInput :: from_toml ( & table, & mut toml_errors) ,
@@ -1022,15 +1022,9 @@ impl Config {
10221022 . 1
10231023 . 0
10241024 . 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 ( ) ) )
10321026 . 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 ( ) ) )
10341028 . chain ( config. validation_errors . 0 . iter ( ) )
10351029 . cloned ( )
10361030 . collect ( ) ,
@@ -1070,6 +1064,7 @@ impl ConfigChange {
10701064 vfs_path : VfsPath ,
10711065 content : Option < Arc < str > > ,
10721066 ) -> Option < ( VfsPath , Option < Arc < str > > ) > {
1067+ dbg ! ( "change_ratoml" , & vfs_path) ;
10731068 self . ratoml_file_change
10741069 . get_or_insert_with ( Default :: default)
10751070 . insert ( source_root, ( vfs_path, content) )
@@ -1086,6 +1081,7 @@ impl ConfigChange {
10861081 vfs_path : VfsPath ,
10871082 content : Option < Arc < str > > ,
10881083 ) -> Option < ( VfsPath , Option < Arc < str > > ) > {
1084+ dbg ! ( "change_workspace" , & vfs_path) ;
10891085 self . workspace_ratoml_change
10901086 . get_or_insert_with ( Default :: default)
10911087 . insert ( source_root, ( vfs_path, content) )
@@ -1350,14 +1346,14 @@ impl Config {
13501346 workspace_roots,
13511347 visual_studio_code_version,
13521348 client_config : ( FullConfigInput :: default ( ) , ConfigErrors ( vec ! [ ] ) ) ,
1353- ratoml_files : FxHashMap :: default ( ) ,
1349+ krate_ratoml : FxHashMap :: default ( ) ,
13541350 default_config : DEFAULT_CONFIG_DATA . get_or_init ( || Box :: leak ( Box :: default ( ) ) ) ,
13551351 source_root_parent_map : Arc :: new ( FxHashMap :: default ( ) ) ,
13561352 user_config : None ,
13571353 user_config_path,
13581354 detached_files : Default :: default ( ) ,
13591355 validation_errors : Default :: default ( ) ,
1360- workspace_ratoml_change : Default :: default ( ) ,
1356+ workspace_ratoml : Default :: default ( ) ,
13611357 }
13621358 }
13631359
@@ -1877,16 +1873,16 @@ impl Config {
18771873 }
18781874 }
18791875
1880- pub fn rustfmt ( & self ) -> RustfmtConfig {
1876+ pub fn rustfmt ( & self , source_root_id : Option < SourceRootId > ) -> RustfmtConfig {
18811877 match & self . rustfmt_overrideCommand ( None ) {
18821878 Some ( args) if !args. is_empty ( ) => {
18831879 let mut args = args. clone ( ) ;
18841880 let command = args. remove ( 0 ) ;
18851881 RustfmtConfig :: CustomCommand { command, args }
18861882 }
18871883 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 ) ,
18901886 } ,
18911887 }
18921888 }
@@ -2540,22 +2536,28 @@ macro_rules! _impl_for_config_data {
25402536 $( $doc) *
25412537 #[ allow( non_snake_case) ]
25422538 $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) {
25472547 if let Some ( value) = config. $field. as_ref( ) {
25482548 return value;
25492549 }
25502550 }
25512551 }
25522552
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+ }
25592561
25602562 if let Some ( v) = self . client_config. 0 . local. $field. as_ref( ) {
25612563 return & v;
@@ -2582,12 +2584,22 @@ macro_rules! _impl_for_config_data {
25822584 $( $doc) *
25832585 #[ allow( non_snake_case) ]
25842586 $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+ }
25912603
25922604 if let Some ( v) = self . client_config. 0 . global. $field. as_ref( ) {
25932605 return & v;
0 commit comments