Skip to content

Commit ffc6cdd

Browse files
committed
Fix: transform the asciidoc form link to markdown style when generating the package.json
1 parent 1a24ee9 commit ffc6cdd

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,21 @@ mod tests {
12891289
.to_string();
12901290
schema.push_str(",\n");
12911291

1292+
let mut new_schema = schema.clone();
1293+
let url_matches = schema.match_indices("https://");
1294+
let mut cnt = 0;
1295+
for (idx, _) in url_matches {
1296+
let link = &schema[idx..];
1297+
// matching on whitespace to ignore normal links
1298+
if let Some(link_end) = link.find(|c| c == ' ' || c == '[') {
1299+
if link.chars().nth(link_end) == Some('[') {
1300+
new_schema.insert(idx + cnt, '(');
1301+
new_schema.insert(idx + link_end + cnt + 1, ')');
1302+
cnt = cnt + 2;
1303+
}
1304+
}
1305+
}
1306+
12921307
let package_json_path = project_root().join("editors/code/package.json");
12931308
let mut package_json = fs::read_to_string(&package_json_path).unwrap();
12941309

@@ -1299,9 +1314,9 @@ mod tests {
12991314
let end = package_json.find(end_marker).unwrap();
13001315

13011316
let p = remove_ws(&package_json[start..end]);
1302-
let s = remove_ws(&schema);
1317+
let s = remove_ws(&new_schema);
13031318
if !p.contains(&s) {
1304-
package_json.replace_range(start..end, &schema);
1319+
package_json.replace_range(start..end, &new_schema);
13051320
ensure_file_contents(&package_json_path, &package_json)
13061321
}
13071322
}

editors/code/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@
436436
]
437437
},
438438
"rust-analyzer.assist.importGroup": {
439-
"markdownDescription": "Group inserted imports by the https://rust-analyzer.github.io/manual.html#auto-import [following order]. Groups are separated by newlines.",
439+
"markdownDescription": "Group inserted imports by the (https://rust-analyzer.github.io/manual.html#auto-import)[following order]. Groups are separated by newlines.",
440440
"default": true,
441441
"type": "boolean"
442442
},

0 commit comments

Comments
 (0)