Put back Project's completion-documention handler (#6451)
This restores the ability for project guests to see documentation on
autocomplete suggestions.
@ForLoveOfCats This code might have gotten lost during the GPUI upgrade.
I'm not sure what happened. I tested this locally, and it seems to fix
completion docs for guests. Could you 👀 and see if there are any tests
or any other code that got lost along with this during the upgrade?
This commit is contained in:
parent
9fd0938eb1
commit
039ef1ad5a
1 changed files with 35 additions and 0 deletions
|
@ -590,6 +590,7 @@ impl Project {
|
||||||
client.add_model_request_handler(Self::handle_delete_project_entry);
|
client.add_model_request_handler(Self::handle_delete_project_entry);
|
||||||
client.add_model_request_handler(Self::handle_expand_project_entry);
|
client.add_model_request_handler(Self::handle_expand_project_entry);
|
||||||
client.add_model_request_handler(Self::handle_apply_additional_edits_for_completion);
|
client.add_model_request_handler(Self::handle_apply_additional_edits_for_completion);
|
||||||
|
client.add_model_request_handler(Self::handle_resolve_completion_documentation);
|
||||||
client.add_model_request_handler(Self::handle_apply_code_action);
|
client.add_model_request_handler(Self::handle_apply_code_action);
|
||||||
client.add_model_request_handler(Self::handle_on_type_formatting);
|
client.add_model_request_handler(Self::handle_on_type_formatting);
|
||||||
client.add_model_request_handler(Self::handle_inlay_hints);
|
client.add_model_request_handler(Self::handle_inlay_hints);
|
||||||
|
@ -7726,6 +7727,40 @@ impl Project {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn handle_resolve_completion_documentation(
|
||||||
|
this: Model<Self>,
|
||||||
|
envelope: TypedEnvelope<proto::ResolveCompletionDocumentation>,
|
||||||
|
_: Arc<Client>,
|
||||||
|
mut cx: AsyncAppContext,
|
||||||
|
) -> Result<proto::ResolveCompletionDocumentationResponse> {
|
||||||
|
let lsp_completion = serde_json::from_slice(&envelope.payload.lsp_completion)?;
|
||||||
|
|
||||||
|
let completion = this
|
||||||
|
.read_with(&mut cx, |this, _| {
|
||||||
|
let id = LanguageServerId(envelope.payload.language_server_id as usize);
|
||||||
|
let Some(server) = this.language_server_for_id(id) else {
|
||||||
|
return Err(anyhow!("No language server {id}"));
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(server.request::<lsp::request::ResolveCompletionItem>(lsp_completion))
|
||||||
|
})??
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let mut is_markdown = false;
|
||||||
|
let text = match completion.documentation {
|
||||||
|
Some(lsp::Documentation::String(text)) => text,
|
||||||
|
|
||||||
|
Some(lsp::Documentation::MarkupContent(lsp::MarkupContent { kind, value })) => {
|
||||||
|
is_markdown = kind == lsp::MarkupKind::Markdown;
|
||||||
|
value
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => String::new(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(proto::ResolveCompletionDocumentationResponse { text, is_markdown })
|
||||||
|
}
|
||||||
|
|
||||||
async fn handle_apply_code_action(
|
async fn handle_apply_code_action(
|
||||||
this: Model<Self>,
|
this: Model<Self>,
|
||||||
envelope: TypedEnvelope<proto::ApplyCodeAction>,
|
envelope: TypedEnvelope<proto::ApplyCodeAction>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue