mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Better handling of block doc comments
This commit is contained in:
parent
0fbfab3b45
commit
ec824a92d0
8 changed files with 158 additions and 81 deletions
|
@ -95,12 +95,10 @@ fn extract_positioned_link_from_comment(
|
|||
let comment_range = comment.syntax().text_range();
|
||||
let doc_comment = comment.doc_comment()?;
|
||||
let def_links = extract_definitions_from_markdown(doc_comment);
|
||||
let start = comment_range.start() + TextSize::from(comment.prefix().len() as u32);
|
||||
let (def_link, ns, _) = def_links.iter().min_by_key(|(_, _, def_link_range)| {
|
||||
let matched_position = comment_range.start() + TextSize::from(def_link_range.start as u32);
|
||||
match position.offset.checked_sub(matched_position) {
|
||||
Some(distance) => distance,
|
||||
None => comment_range.end(),
|
||||
}
|
||||
let matched_position = start + TextSize::from(def_link_range.start as u32);
|
||||
position.offset.checked_sub(matched_position).unwrap_or_else(|| comment_range.end())
|
||||
})?;
|
||||
Some((def_link.to_string(), *ns))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue