Fix a panic when diagnostics contain multiple links (#16601)
Follow up from #14518 Release Notes: - Fixed a panic when diagnostics contain multiple links
This commit is contained in:
parent
8a5fcc2c22
commit
09c698d8d7
2 changed files with 42 additions and 3 deletions
|
@ -96,8 +96,8 @@ pub fn parse_links_only(text: &str) -> Vec<(Range<usize>, MarkdownEvent)> {
|
|||
start: 0,
|
||||
end: text.len(),
|
||||
};
|
||||
for link in finder.links(&text[text_range.clone()]) {
|
||||
let link_range = text_range.start + link.start()..text_range.start + link.end();
|
||||
for link in finder.links(&text) {
|
||||
let link_range = link.start()..link.end();
|
||||
|
||||
if link_range.start > text_range.start {
|
||||
events.push((text_range.start..link_range.start, MarkdownEvent::Text));
|
||||
|
@ -118,7 +118,9 @@ pub fn parse_links_only(text: &str) -> Vec<(Range<usize>, MarkdownEvent)> {
|
|||
text_range.start = link_range.end;
|
||||
}
|
||||
|
||||
events.push((text_range, MarkdownEvent::Text));
|
||||
if text_range.end > text_range.start {
|
||||
events.push((text_range, MarkdownEvent::Text));
|
||||
}
|
||||
|
||||
events
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue