@@ -117,7 +117,7 @@ impl ConfigFile {
117
117
val. get ( "value" ) . is_some ( ) && val. get ( "sources" ) . is_some ( ) && val. get ( "sources" ) . unwrap ( ) . is_array ( )
118
118
}
119
119
120
- fn render_field ( key : & str , value : & serde_json:: Value ) -> String {
120
+ fn render_field ( key : & str , value : & serde_json:: Value , ident : usize ) -> String {
121
121
let mut rows = String :: new ( ) ;
122
122
if is_sourced_field ( value) {
123
123
let val = & value[ "value" ] ;
@@ -131,7 +131,7 @@ impl ConfigFile {
131
131
// Nested object
132
132
rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" >{} = {{</div><div class=\" toml-right\" ></div></div>\n " , key) ) ;
133
133
for ( k, v) in val. as_object ( ) . unwrap ( ) {
134
- for line in render_field ( k, v) . lines ( ) {
134
+ for line in render_field ( k, v, ident + 1 ) . lines ( ) {
135
135
rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" > {}</div></div>\n " , line) ) ;
136
136
}
137
137
}
@@ -148,15 +148,15 @@ impl ConfigFile {
148
148
. map ( render_source)
149
149
. collect :: < Vec < _ > > ( )
150
150
. join ( ", " ) ;
151
- rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" > {} ,</div><div class=\" toml-right\" >{}</div></div>\n " , item_val, item_rendered_src) ) ;
151
+ rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" >{}{} ,</div><div class=\" toml-right\" >{}</div></div>\n " , " " . repeat ( ( ident + 1 ) * 2 ) , item_val, item_rendered_src) ) ;
152
152
} else {
153
- rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" > {} ,</div><div class=\" toml-right\" >{}</div></div>\n " , item, rendered_src) ) ;
153
+ rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" >{}{} ,</div><div class=\" toml-right\" >{}</div></div>\n " , " " . repeat ( ( ident + 1 ) * 2 ) , item, rendered_src) ) ;
154
154
}
155
155
}
156
156
rows. push_str ( "<div class=\" toml-row\" ><div class=\" toml-left\" >]</div><div class=\" toml-right\" ></div></div>\n " ) ;
157
157
} else {
158
158
// Single value
159
- rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" >{} = {}</div><div class=\" toml-right\" >{}</div></div>\n " , key, val, rendered_src) ) ;
159
+ rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" >{}{} = {}</div><div class=\" toml-right\" >{}</div></div>\n " , " " . repeat ( ident * 2 ) , key, val, rendered_src) ) ;
160
160
}
161
161
} else if value. is_array ( ) {
162
162
// Array of Sourced or primitive values
@@ -170,24 +170,24 @@ impl ConfigFile {
170
170
. map ( render_source)
171
171
. collect :: < Vec < _ > > ( )
172
172
. join ( ", " ) ;
173
- rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" > {} ,</div><div class=\" toml-right\" >{}</div></div>\n " , item_val, item_rendered_src) ) ;
173
+ rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" >{}{} ,</div><div class=\" toml-right\" >{}</div></div>\n " , " " . repeat ( ( ident + 1 ) * 2 ) , item_val, item_rendered_src) ) ;
174
174
} else {
175
- rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" > {} ,</div><div class=\" toml-right\" ></div></div>\n " , item) ) ;
175
+ rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" >{}{} ,</div><div class=\" toml-right\" ></div></div>\n " , " " . repeat ( ( ident + 1 ) * 2 ) , item) ) ;
176
176
}
177
177
}
178
178
rows. push_str ( "<div class=\" toml-row\" ><div class=\" toml-left\" >]</div><div class=\" toml-right\" ></div></div>\n " ) ;
179
179
} else if value. is_object ( ) && !value. is_null ( ) {
180
180
// Nested object
181
181
rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" >{} = {{</div><div class=\" toml-right\" ></div></div>\n " , key) ) ;
182
182
for ( k, v) in value. as_object ( ) . unwrap ( ) {
183
- for line in render_field ( k, v) . lines ( ) {
184
- rows. push_str ( & format ! ( "<div class= \" toml-row \" ><div class= \" toml-left \" > {}</div></div> \n " , line) ) ;
183
+ for line in render_field ( k, v, ident + 1 ) . lines ( ) {
184
+ rows. push_str ( line) ;
185
185
}
186
186
}
187
187
rows. push_str ( "<div class=\" toml-row\" ><div class=\" toml-left\" >}</div><div class=\" toml-right\" ></div></div>\n " ) ;
188
188
} else {
189
189
// Primitive value
190
- rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" >{} = {}</div><div class=\" toml-right\" ></div></div>\n " , key, value) ) ;
190
+ rows. push_str ( & format ! ( "<div class=\" toml-row\" ><div class=\" toml-left\" >{}{} = {}</div><div class=\" toml-right\" ></div></div>\n " , " " . repeat ( ident * 2 ) , key, value) ) ;
191
191
}
192
192
rows
193
193
}
@@ -233,7 +233,7 @@ impl ConfigFile {
233
233
] ;
234
234
for key in order {
235
235
if let Some ( val) = map. get ( key) {
236
- entry_html. push_str ( & render_field ( key, val) ) ;
236
+ entry_html. push_str ( & render_field ( key, val, 0 ) ) ;
237
237
}
238
238
}
239
239
}
@@ -671,17 +671,17 @@ fn read_config_from_file<P: AsRef<Path>>(path: P) -> Result<HashMap<String, Conf
671
671
672
672
let config = raw. config . into_iter ( ) . map ( |mut entry| {
673
673
// odoo_path
674
- entry. odoo_path . as_mut ( ) . map ( |sourced| { sourced. sources . insert ( path. sanitize ( ) ) ; } ) ;
674
+ entry. odoo_path . iter_mut ( ) . for_each ( |sourced| { sourced. sources . insert ( path. sanitize ( ) ) ; } ) ;
675
675
676
676
// addons_paths
677
- entry. addons_paths . as_mut ( ) . map ( |paths| {
677
+ entry. addons_paths . iter_mut ( ) . for_each ( |paths| {
678
678
paths. iter_mut ( ) . for_each ( |sourced| {
679
679
sourced. sources . insert ( path. sanitize ( ) ) ;
680
680
} ) ;
681
681
} ) ;
682
682
683
683
// additional_stubs
684
- entry. additional_stubs . as_mut ( ) . map ( |stubs| {
684
+ entry. additional_stubs . iter_mut ( ) . for_each ( |stubs| {
685
685
stubs. iter_mut ( ) . for_each ( |sourced| {
686
686
sourced. sources . insert ( path. sanitize ( ) ) ;
687
687
} ) ;
@@ -700,6 +700,9 @@ fn read_config_from_file<P: AsRef<Path>>(path: P) -> Result<HashMap<String, Conf
700
700
entry. auto_refresh_delay . as_mut ( ) . map ( |sourced| sourced. sources . insert ( path. sanitize ( ) ) ) ;
701
701
entry. add_workspace_addon_path . as_mut ( ) . map ( |sourced| sourced. sources . insert ( path. sanitize ( ) ) ) ;
702
702
entry. version . as_mut ( ) . map ( |sourced| sourced. sources . insert ( path. sanitize ( ) ) ) ;
703
+ entry. diagnostic_settings . values_mut ( ) . for_each ( |sourced| {
704
+ sourced. sources . insert ( path. sanitize ( ) ) ;
705
+ } ) ;
703
706
704
707
( entry. name . clone ( ) , entry)
705
708
} ) . collect ( ) ;
0 commit comments