Fixed native rust goto
This commit is contained in:
@@ -756,8 +756,7 @@ impl LanguageServer for Backend {
|
|||||||
{
|
{
|
||||||
Ok(Some(GotoDefinitionResponse::Scalar(loc))) => {
|
Ok(Some(GotoDefinitionResponse::Scalar(loc))) => {
|
||||||
eprintln!("[goto_definition] Scalar response");
|
eprintln!("[goto_definition] Scalar response");
|
||||||
let mapped = self.map_rust_to_mist_pos(&loc.uri, &loc.range.start).await;
|
match self.map_rust_to_mist_pos(&loc.uri, &loc.range.start).await {
|
||||||
match mapped {
|
|
||||||
Some((mist_uri, mist_start)) => {
|
Some((mist_uri, mist_start)) => {
|
||||||
let mist_range = Range {
|
let mist_range = Range {
|
||||||
start: mist_start,
|
start: mist_start,
|
||||||
@@ -772,11 +771,18 @@ impl LanguageServer for Backend {
|
|||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
eprintln!("[goto_definition] map_rust_to_mist_pos failed, returning raw rust loc");
|
if let Some(normalized) = loc.uri.to_file_path().ok().and_then(|p| clean_lsp_url(&p)) {
|
||||||
|
eprintln!("[goto_definition] returning raw rust loc");
|
||||||
|
Ok(Some(GotoDefinitionResponse::Scalar(Location {
|
||||||
|
uri: normalized,
|
||||||
|
range: loc.range,
|
||||||
|
})))
|
||||||
|
} else {
|
||||||
Ok(Some(GotoDefinitionResponse::Scalar(loc)))
|
Ok(Some(GotoDefinitionResponse::Scalar(loc)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ok(Some(GotoDefinitionResponse::Array(locs))) => {
|
Ok(Some(GotoDefinitionResponse::Array(locs))) => {
|
||||||
eprintln!("[goto_definition] Array response with {} items", locs.len());
|
eprintln!("[goto_definition] Array response with {} items", locs.len());
|
||||||
let mut mapped = Vec::new();
|
let mut mapped = Vec::new();
|
||||||
@@ -794,6 +800,11 @@ impl LanguageServer for Backend {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else if let Some(normalized) = loc.uri.to_file_path().ok().and_then(|p| clean_lsp_url(&p)) {
|
||||||
|
mapped.push(Location {
|
||||||
|
uri: normalized,
|
||||||
|
range: loc.range,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(Some(GotoDefinitionResponse::Array(mapped)))
|
Ok(Some(GotoDefinitionResponse::Array(mapped)))
|
||||||
@@ -824,6 +835,15 @@ impl LanguageServer for Backend {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else if let Some(normalized) =
|
||||||
|
link.target_uri.to_file_path().ok().and_then(|p| clean_lsp_url(&p))
|
||||||
|
{
|
||||||
|
mapped.push(LocationLink {
|
||||||
|
origin_selection_range: link.origin_selection_range,
|
||||||
|
target_uri: normalized,
|
||||||
|
target_range: link.target_range,
|
||||||
|
target_selection_range: link.target_selection_range,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(Some(GotoDefinitionResponse::Link(mapped)))
|
Ok(Some(GotoDefinitionResponse::Link(mapped)))
|
||||||
|
|||||||
Reference in New Issue
Block a user