@@ -13,7 +13,7 @@ import { getUriPath } from '../UriPaths';
13
13
import { ProvisionalCompletionOrchestrator } from './ProvisionalCompletionOrchestrator' ;
14
14
import { LanguageKind } from '../RPC/LanguageKind' ;
15
15
import { RoslynLanguageServer } from '../../../lsptoolshost/roslynLanguageServer' ;
16
- import { CompletionItem , CompletionParams , CompletionTriggerKind } from 'vscode-languageclient' ;
16
+ import { CompletionItem , CompletionList , CompletionParams , CompletionTriggerKind , MarkupContent } from 'vscode-languageclient' ;
17
17
import { UriConverter } from '../../../lsptoolshost/uriConverter' ;
18
18
import * as RazorConventions from '../RazorConventions' ;
19
19
import { MappingHelpers } from '../Mapping/MappingHelpers' ;
@@ -35,11 +35,6 @@ export class RazorCompletionItemProvider
35
35
36
36
let completions : vscode . CompletionList | vscode . CompletionItem [ ] ;
37
37
38
- // For CSharp, completions need to keep the "data" field
39
- // on the completion item for lazily resolving the edits in
40
- // the resolveCompletionItem step. Using the vs code command
41
- // drops that field because it doesn't exist in the declared vs code
42
- // CompletionItem type.
43
38
if ( language === LanguageKind . CSharp ) {
44
39
const params : CompletionParams = {
45
40
context : {
@@ -52,6 +47,11 @@ export class RazorCompletionItemProvider
52
47
position : projectedPosition
53
48
} ;
54
49
50
+ // For CSharp, completions need to keep the "data" field on the
51
+ // completion item for lazily resolving the edits in the
52
+ // resolveCompletionItem step. Using the vs code command drops
53
+ // that field because it doesn't exist in the declared vs code
54
+ // CompletionItem type.
55
55
completions = await vscode
56
56
. commands
57
57
. executeCommand < vscode . CompletionList | vscode . CompletionItem [ ] > (
@@ -71,6 +71,8 @@ export class RazorCompletionItemProvider
71
71
completions instanceof Array ? completions // was vscode.CompletionItem[]
72
72
: completions ? completions . items // was vscode.CompletionList
73
73
: [ ] ;
74
+
75
+ const data = ( < CompletionList > completions ) ?. itemDefaults ?. data ;
74
76
75
77
// There are times when the generated code will not line up with the content of the .razor/.cshtml file.
76
78
// Therefore, we need to offset all completion items' characters by a certain amount in order
@@ -79,7 +81,7 @@ export class RazorCompletionItemProvider
79
81
const completionCharacterOffset = projectedPosition . character - hostDocumentPosition . character ;
80
82
for ( const completionItem of completionItems ) {
81
83
const doc = completionItem . documentation as vscode . MarkdownString ;
82
- if ( doc ) {
84
+ if ( doc && doc . value ) {
83
85
// Without this, the documentation doesn't get rendered in the editor.
84
86
const newDoc = new vscode . MarkdownString ( doc . value ) ;
85
87
newDoc . isTrusted = doc . isTrusted ;
@@ -128,6 +130,10 @@ export class RazorCompletionItemProvider
128
130
completionItem . insertText = intellicodeCompletion . textEditText ;
129
131
}
130
132
}
133
+
134
+ if ( ! ( < CompletionItem > completionItem ) . data ) {
135
+ ( < CompletionItem > completionItem ) . data = data ;
136
+ }
131
137
}
132
138
133
139
const isIncomplete = completions instanceof Array ? false
@@ -204,6 +210,13 @@ export class RazorCompletionItemProvider
204
210
205
211
item = newItem ;
206
212
213
+ // The documentation object Roslyn returns is a MarkupContent,
214
+ // which we need to convert to a MarkdownString.
215
+ const markupContent = < MarkupContent > ( < unknown > ( item . documentation ) ) ;
216
+ if ( markupContent && markupContent . value ) {
217
+ item . documentation = new vscode . MarkdownString ( markupContent . value ) ;
218
+ }
219
+
207
220
if ( item . command && item . command . arguments ?. length === 4 ) {
208
221
let uri = vscode . Uri . parse ( item . command . arguments [ 0 ] ) ;
209
222
@@ -238,4 +251,3 @@ function getTriggerKind(triggerKind: vscode.CompletionTriggerKind): CompletionTr
238
251
239
252
}
240
253
}
241
-
0 commit comments