Fixed native rust goto

This commit is contained in:
2026-06-22 00:23:50 +02:00
parent 48c24235b1
commit b69168f135
+24 -4
View File
@@ -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,8 +771,15 @@ 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)) {
Ok(Some(GotoDefinitionResponse::Scalar(loc))) eprintln!("[goto_definition] returning raw rust loc");
Ok(Some(GotoDefinitionResponse::Scalar(Location {
uri: normalized,
range: loc.range,
})))
} else {
Ok(Some(GotoDefinitionResponse::Scalar(loc)))
}
} }
} }
} }
@@ -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)))