Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c6f776c

Browse files
committed
determine doc link type from start instead of text or code
1 parent eb9b360 commit c6f776c

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

crates/ide/src/doc_links.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,15 @@ fn map_links<'e>(
362362
// holds the origin link target on start event and the rewritten one on end event
363363
let mut end_link_target: Option<CowStr> = None;
364364
// normally link's type is determined by the type of link tag in the end event,
365-
// however in same cases we want to change the link type, for example,
365+
// however in some cases we want to change the link type, for example,
366366
// `Shortcut` type doesn't make sense for url links
367367
let mut end_link_type: Option<LinkType> = None;
368368

369369
events.map(move |evt| match evt {
370-
Event::Start(Tag::Link(_, ref target, _)) => {
370+
Event::Start(Tag::Link(link_type, ref target, _)) => {
371371
in_link = true;
372372
end_link_target = Some(target.clone());
373+
end_link_type = Some(link_type);
373374
evt
374375
}
375376
Event::End(Tag::Link(link_type, target, _)) => {
@@ -381,17 +382,13 @@ fn map_links<'e>(
381382
))
382383
}
383384
Event::Text(s) if in_link => {
384-
let (link_type, link_target_s, link_name) =
385-
callback(&end_link_target.take().unwrap(), &s);
385+
let (_, link_target_s, link_name) = callback(&end_link_target.take().unwrap(), &s);
386386
end_link_target = Some(CowStr::Boxed(link_target_s.into()));
387-
end_link_type = link_type;
388387
Event::Text(CowStr::Boxed(link_name.into()))
389388
}
390389
Event::Code(s) if in_link => {
391-
let (link_type, link_target_s, link_name) =
392-
callback(&end_link_target.take().unwrap(), &s);
390+
let (_, link_target_s, link_name) = callback(&end_link_target.take().unwrap(), &s);
393391
end_link_target = Some(CowStr::Boxed(link_target_s.into()));
394-
end_link_type = link_type;
395392
Event::Code(CowStr::Boxed(link_name.into()))
396393
}
397394
_ => evt,

0 commit comments

Comments
 (0)