@@ -1615,10 +1615,6 @@ impl LspStore {
1615
1615
let ( server_id, completion) = {
1616
1616
let completions_guard = completions. read ( ) ;
1617
1617
let completion = & completions_guard[ completion_index] ;
1618
- if completion. documentation . is_some ( ) {
1619
- continue ;
1620
- }
1621
-
1622
1618
did_resolve = true ;
1623
1619
let server_id = completion. server_id ;
1624
1620
let completion = completion. lsp_completion . clone ( ) ;
@@ -1643,10 +1639,6 @@ impl LspStore {
1643
1639
let ( server_id, completion) = {
1644
1640
let completions_guard = completions. read ( ) ;
1645
1641
let completion = & completions_guard[ completion_index] ;
1646
- if completion. documentation . is_some ( ) {
1647
- continue ;
1648
- }
1649
-
1650
1642
let server_id = completion. server_id ;
1651
1643
let completion = completion. lsp_completion . clone ( ) ;
1652
1644
@@ -1743,6 +1735,10 @@ impl LspStore {
1743
1735
completion. lsp_completion . insert_text_format = completion_item. insert_text_format ;
1744
1736
}
1745
1737
}
1738
+
1739
+ let mut completions = completions. write ( ) ;
1740
+ let completion = & mut completions[ completion_index] ;
1741
+ completion. lsp_completion = completion_item;
1746
1742
}
1747
1743
1748
1744
#[ allow( clippy:: too_many_arguments) ]
@@ -1771,6 +1767,10 @@ impl LspStore {
1771
1767
else {
1772
1768
return ;
1773
1769
} ;
1770
+ let Some ( lsp_completion) = serde_json:: from_slice ( & response. lsp_completion ) . log_err ( )
1771
+ else {
1772
+ return ;
1773
+ } ;
1774
1774
1775
1775
let documentation = if response. documentation . is_empty ( ) {
1776
1776
Documentation :: Undocumented
@@ -1787,6 +1787,7 @@ impl LspStore {
1787
1787
let mut completions = completions. write ( ) ;
1788
1788
let completion = & mut completions[ completion_index] ;
1789
1789
completion. documentation = Some ( documentation) ;
1790
+ completion. lsp_completion = lsp_completion;
1790
1791
1791
1792
let old_range = response
1792
1793
. old_start
@@ -4192,17 +4193,32 @@ impl LspStore {
4192
4193
let lsp_completion = serde_json:: from_slice ( & envelope. payload . lsp_completion ) ?;
4193
4194
4194
4195
let completion = this
4195
- . read_with ( & cx, |this, _ | {
4196
+ . read_with ( & cx, |this, cx | {
4196
4197
let id = LanguageServerId ( envelope. payload . language_server_id as usize ) ;
4197
4198
let Some ( server) = this. language_server_for_id ( id) else {
4198
4199
return Err ( anyhow ! ( "No language server {id}" ) ) ;
4199
4200
} ;
4200
4201
4201
- 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
+ } ) )
4202
4217
} ) ??
4203
4218
. await ?;
4204
4219
4205
4220
let mut documentation_is_markdown = false ;
4221
+ let lsp_completion = serde_json:: to_string ( & completion) ?. into_bytes ( ) ;
4206
4222
let documentation = match completion. documentation {
4207
4223
Some ( lsp:: Documentation :: String ( text) ) => text,
4208
4224
@@ -4244,6 +4260,7 @@ impl LspStore {
4244
4260
old_start,
4245
4261
old_end,
4246
4262
new_text,
4263
+ lsp_completion,
4247
4264
} )
4248
4265
}
4249
4266
0 commit comments