mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Correctly generate link fragments for associated items
This commit is contained in:
parent
113beab473
commit
e8f1abf5f7
4 changed files with 164 additions and 124 deletions
|
@ -19,7 +19,7 @@ use syntax::{
|
|||
use crate::{
|
||||
display::{macro_label, TryToNav},
|
||||
doc_links::{
|
||||
doc_attributes, extract_definitions_from_markdown, remove_links, resolve_doc_path_for_def,
|
||||
doc_attributes, extract_definitions_from_docs, remove_links, resolve_doc_path_for_def,
|
||||
rewrite_links,
|
||||
},
|
||||
markdown_remove::remove_markdown,
|
||||
|
@ -119,7 +119,7 @@ pub(crate) fn hover(
|
|||
let (attributes, def) = doc_attributes(&sema, &node)?;
|
||||
let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?;
|
||||
let (idl_range, link, ns) =
|
||||
extract_definitions_from_markdown(docs.as_str()).into_iter().find_map(|(range, link, ns)| {
|
||||
extract_definitions_from_docs(&docs).into_iter().find_map(|(range, link, ns)| {
|
||||
let hir::InFile { file_id, value: range } = doc_mapping.map(range)?;
|
||||
if file_id == position.file_id.into() && range.contains(position.offset) {
|
||||
Some((range, link, ns))
|
||||
|
@ -369,7 +369,7 @@ fn process_markup(
|
|||
let markup = if !config.markdown() {
|
||||
remove_markdown(markup)
|
||||
} else if config.links_in_hover {
|
||||
rewrite_links(db, markup, &def)
|
||||
rewrite_links(db, markup, def)
|
||||
} else {
|
||||
remove_links(markup)
|
||||
};
|
||||
|
@ -2090,7 +2090,7 @@ pub trait Foo {
|
|||
/// [buzz]: Foo::buzz
|
||||
pub struct B$0ar
|
||||
"#,
|
||||
expect
|
||||
"#]],
|
||||
[Foo](https://docs.rs/test/*/test/trait.Foo.html#method.buzz)
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue