Skip to content

Commit dc10748

Browse files
authored
Update config.rs
1 parent b885cea commit dc10748

File tree

1 file changed

+14
-6
lines changed
  • src/tools/rust-analyzer/crates/rust-analyzer/src

1 file changed

+14
-6
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -2634,11 +2634,19 @@ fn schema(fields: &[SchemaField]) -> serde_json::Value {
26342634
.iter()
26352635
.map(|(field, ty, doc, default)| {
26362636
let name = field.replace('_', ".");
2637+
let catagory = name.find('.').map(|end| {
2638+
String::from(&name[..end])
2639+
}).unwrap_or("general".into());
26372640
let name = format!("rust-analyzer.{name}");
26382641
let props = field_props(field, ty, doc, default);
2639-
(name, props)
2642+
serde_json::json!({
2643+
"title": catagory,
2644+
"properties": {
2645+
name: props
2646+
}
2647+
})
26402648
})
2641-
.collect::<serde_json::Map<_, _>>();
2649+
.collect::<Vec<_>>();
26422650
map.into()
26432651
}
26442652

@@ -3037,8 +3045,8 @@ mod tests {
30373045
let s = Config::json_schema();
30383046
let schema = format!("{s:#}");
30393047
let mut schema = schema
3040-
.trim_start_matches('{')
3041-
.trim_end_matches('}')
3048+
.trim_start_matches('[')
3049+
.trim_end_matches(']')
30423050
.replace(" ", " ")
30433051
.replace('\n', "\n ")
30443052
.trim_start_matches('\n')
@@ -3072,8 +3080,8 @@ mod tests {
30723080
let package_json_path = project_root().join("editors/code/package.json");
30733081
let mut package_json = fs::read_to_string(&package_json_path).unwrap();
30743082

3075-
let start_marker = " \"$generated-start\": {},\n";
3076-
let end_marker = " \"$generated-end\": {}\n";
3083+
let start_marker = " { \"title\": \"$generated-start\" },\n";
3084+
let end_marker = " { \"title\": \"$generated-end\" }\n";
30773085

30783086
let start = package_json.find(start_marker).unwrap() + start_marker.len();
30793087
let end = package_json.find(end_marker).unwrap();

0 commit comments

Comments
 (0)