diff options
Diffstat (limited to 'crates/ide/src/goto_definition.rs')
-rw-r--r-- | crates/ide/src/goto_definition.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs index b71f4917c..5072ecea0 100644 --- a/crates/ide/src/goto_definition.rs +++ b/crates/ide/src/goto_definition.rs | |||
@@ -95,12 +95,10 @@ fn extract_positioned_link_from_comment( | |||
95 | let comment_range = comment.syntax().text_range(); | 95 | let comment_range = comment.syntax().text_range(); |
96 | let doc_comment = comment.doc_comment()?; | 96 | let doc_comment = comment.doc_comment()?; |
97 | let def_links = extract_definitions_from_markdown(doc_comment); | 97 | let def_links = extract_definitions_from_markdown(doc_comment); |
98 | let start = comment_range.start() + TextSize::from(comment.prefix().len() as u32); | ||
98 | let (def_link, ns, _) = def_links.iter().min_by_key(|(_, _, def_link_range)| { | 99 | let (def_link, ns, _) = def_links.iter().min_by_key(|(_, _, def_link_range)| { |
99 | let matched_position = comment_range.start() + TextSize::from(def_link_range.start as u32); | 100 | let matched_position = start + TextSize::from(def_link_range.start as u32); |
100 | match position.offset.checked_sub(matched_position) { | 101 | position.offset.checked_sub(matched_position).unwrap_or_else(|| comment_range.end()) |
101 | Some(distance) => distance, | ||
102 | None => comment_range.end(), | ||
103 | } | ||
104 | })?; | 102 | })?; |
105 | Some((def_link.to_string(), *ns)) | 103 | Some((def_link.to_string(), *ns)) |
106 | } | 104 | } |