@@ -1759,7 +1759,6 @@ impl LspStore {
1759
1759
buffer_id : buffer_id. into ( ) ,
1760
1760
} ;
1761
1761
1762
- // TODO kb this has to return the entire LSP completion instead, not just the docs
1763
1762
let Some ( response) = client
1764
1763
. request ( request)
1765
1764
. await
@@ -1768,6 +1767,10 @@ impl LspStore {
1768
1767
else {
1769
1768
return ;
1770
1769
} ;
1770
+ let Some ( lsp_completion) = serde_json:: from_slice ( & response. lsp_completion ) . log_err ( )
1771
+ else {
1772
+ return ;
1773
+ } ;
1771
1774
1772
1775
let documentation = if response. documentation . is_empty ( ) {
1773
1776
Documentation :: Undocumented
@@ -1784,6 +1787,7 @@ impl LspStore {
1784
1787
let mut completions = completions. write ( ) ;
1785
1788
let completion = & mut completions[ completion_index] ;
1786
1789
completion. documentation = Some ( documentation) ;
1790
+ completion. lsp_completion = lsp_completion;
1787
1791
1788
1792
let old_range = response
1789
1793
. old_start
@@ -4189,17 +4193,32 @@ impl LspStore {
4189
4193
let lsp_completion = serde_json:: from_slice ( & envelope. payload . lsp_completion ) ?;
4190
4194
4191
4195
let completion = this
4192
- . read_with ( & cx, |this, _ | {
4196
+ . read_with ( & cx, |this, cx | {
4193
4197
let id = LanguageServerId ( envelope. payload . language_server_id as usize ) ;
4194
4198
let Some ( server) = this. language_server_for_id ( id) else {
4195
4199
return Err ( anyhow ! ( "No language server {id}" ) ) ;
4196
4200
} ;
4197
4201
4198
- Ok ( server. request :: < lsp:: request:: ResolveCompletionItem > ( lsp_completion) )
4202
+ Ok ( cx. background_executor ( ) . spawn ( async move {
4203
+ let can_resolve = server
4204
+ . capabilities ( )
4205
+ . completion_provider
4206
+ . as_ref ( )
4207
+ . and_then ( |options| options. resolve_provider )
4208
+ . unwrap_or ( false ) ;
4209
+ if can_resolve {
4210
+ server
4211
+ . request :: < lsp:: request:: ResolveCompletionItem > ( lsp_completion)
4212
+ . await
4213
+ } else {
4214
+ anyhow:: Ok ( lsp_completion)
4215
+ }
4216
+ } ) )
4199
4217
} ) ??
4200
4218
. await ?;
4201
4219
4202
4220
let mut documentation_is_markdown = false ;
4221
+ let lsp_completion = serde_json:: to_string ( & completion) ?. into_bytes ( ) ;
4203
4222
let documentation = match completion. documentation {
4204
4223
Some ( lsp:: Documentation :: String ( text) ) => text,
4205
4224
@@ -4241,6 +4260,7 @@ impl LspStore {
4241
4260
old_start,
4242
4261
old_end,
4243
4262
new_text,
4263
+ lsp_completion,
4244
4264
} )
4245
4265
}
4246
4266
0 commit comments