Skip to content

Commit 057558b

Browse files
bors[bot]dzvon
andauthored
Merge #10595
10595: internal: Fix a format error r=Veykril a=dzvon Fixes #10581 Co-authored-by: Dezhi Wu <wu543065657@163.com>
2 parents b025bd6 + 74396d2 commit 057558b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

crates/rust-analyzer/src/config.rs

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

1292+
// Transform the asciidoc form link to markdown style.
1293+
//
1294+
// https://link[text] => [text](https://link)
1295+
let url_matches = schema.match_indices("https://");
1296+
let mut url_offsets = url_matches.map(|(idx, _)| idx).collect::<Vec<usize>>();
1297+
url_offsets.reverse();
1298+
for idx in url_offsets {
1299+
let link = &schema[idx..];
1300+
// matching on whitespace to ignore normal links
1301+
if let Some(link_end) = link.find(|c| c == ' ' || c == '[') {
1302+
if link.chars().nth(link_end) == Some('[') {
1303+
if let Some(link_text_end) = link.find(']') {
1304+
let link_text = link[link_end..(link_text_end + 1)].to_string();
1305+
1306+
schema.replace_range((idx + link_end)..(idx + link_text_end + 1), "");
1307+
schema.insert(idx, '(');
1308+
schema.insert(idx + link_end + 1, ')');
1309+
schema.insert_str(idx, &link_text);
1310+
}
1311+
}
1312+
}
1313+
}
1314+
12921315
let package_json_path = project_root().join("editors/code/package.json");
12931316
let mut package_json = fs::read_to_string(&package_json_path).unwrap();
12941317

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 [following order](https://rust-analyzer.github.io/manual.html#auto-import). Groups are separated by newlines.",
440440
"default": true,
441441
"type": "boolean"
442442
},

0 commit comments

Comments
 (0)