Skip to content

Commit 74396d2

Browse files
committed
Fix: correct markdown link form.
1 parent 097d527 commit 74396d2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,8 @@ mod tests {
12901290
schema.push_str(",\n");
12911291

12921292
// Transform the asciidoc form link to markdown style.
1293+
//
1294+
// https://link[text] => [text](https://link)
12931295
let url_matches = schema.match_indices("https://");
12941296
let mut url_offsets = url_matches.map(|(idx, _)| idx).collect::<Vec<usize>>();
12951297
url_offsets.reverse();
@@ -1298,8 +1300,14 @@ mod tests {
12981300
// matching on whitespace to ignore normal links
12991301
if let Some(link_end) = link.find(|c| c == ' ' || c == '[') {
13001302
if link.chars().nth(link_end) == Some('[') {
1301-
schema.insert(idx, '(');
1302-
schema.insert(idx + link_end + 1, ')');
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+
}
13031311
}
13041312
}
13051313
}

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)