1010using System . Threading . Tasks ;
1111using Microsoft . CodeAnalysis . Completion ;
1212using Microsoft . CodeAnalysis . Host ;
13- using Microsoft . CodeAnalysis . LanguageServer . Handler ;
1413using Microsoft . CodeAnalysis . LanguageServer . Handler . Completion ;
1514using Microsoft . CodeAnalysis . LanguageService ;
1615using Microsoft . CodeAnalysis . Options ;
@@ -65,7 +64,7 @@ void M()
6564 label : "A" ) . ConfigureAwait ( false ) ;
6665
6766 var description = new ClassifiedTextElement ( CreateClassifiedTextRunForClass ( "A" ) ) ;
68- var expected = CreateResolvedCompletionItem ( clientCompletionItem , description , "class A" , null ) ;
67+ var expected = CreateResolvedCompletionItem ( clientCompletionItem , description , null ) ;
6968
7069 var results = ( LSP . VSInternalCompletionItem ) await RunResolveCompletionItemAsync (
7170 testLspServer , clientCompletionItem ) . ConfigureAwait ( false ) ;
@@ -87,7 +86,7 @@ void M()
8786 var clientCompletionItem = await GetCompletionItemToResolveAsync < LSP . VSInternalCompletionItem > ( testLspServer , label : "A" ) . ConfigureAwait ( false ) ;
8887
8988 var description = new ClassifiedTextElement ( CreateClassifiedTextRunForClass ( "A" ) ) ;
90- var expected = CreateResolvedCompletionItem ( clientCompletionItem , description , "class A" , null ) ;
89+ var expected = CreateResolvedCompletionItem ( clientCompletionItem , description , null ) ;
9190
9291 var results = ( LSP . VSInternalCompletionItem ) await RunResolveCompletionItemAsync (
9392 testLspServer , clientCompletionItem ) . ConfigureAwait ( false ) ;
@@ -182,9 +181,9 @@ class B : A
182181
183182 var document = testLspServer . GetCurrentSolution ( ) . Projects . First ( ) . Documents . First ( ) ;
184183
185- var selectedItem = CodeAnalysis . Completion . CompletionItem . Create ( displayText : "M" ) ;
186- var textEdit = await EditorLspCompletionResultCreationService . GenerateTextEditAsync (
187- document , new TestCaretOutOfScopeCompletionService ( testLspServer . TestWorkspace . Services . SolutionServices ) , selectedItem , snippetsSupported : true , CancellationToken . None ) . ConfigureAwait ( false ) ;
184+ var selectedItem = CodeAnalysis . Completion . CompletionItem . Create ( displayText : "M" , isComplexTextEdit : true ) ;
185+ var ( textEdit , _ , _ ) = await AbstractLspCompletionResultCreationService . GenerateComplexTextEditAsync (
186+ document , new TestCaretOutOfScopeCompletionService ( testLspServer . TestWorkspace . Services . SolutionServices ) , selectedItem , snippetsSupported : true , insertNewPositionPlaceholder : true , CancellationToken . None ) . ConfigureAwait ( false ) ;
188187
189188 Assert . Equal ( @"public override void M()
190189 {
@@ -353,24 +352,51 @@ void M()
353352 completionItem , CancellationToken . None ) ;
354353 }
355354
356- private static LSP . VSInternalCompletionItem CreateResolvedCompletionItem (
355+ private static VSInternalCompletionItem Clone ( VSInternalCompletionItem completionItem )
356+ {
357+ return new VSInternalCompletionItem ( )
358+ {
359+ Label = completionItem . Label ,
360+ LabelDetails = completionItem . LabelDetails ,
361+ Kind = completionItem . Kind ,
362+ Detail = completionItem . Detail ,
363+ Documentation = completionItem . Documentation ,
364+ Preselect = completionItem . Preselect ,
365+ SortText = completionItem . SortText ,
366+ FilterText = completionItem . FilterText ,
367+ InsertText = completionItem . InsertText ,
368+ InsertTextFormat = completionItem . InsertTextFormat ,
369+ TextEdit = completionItem . TextEdit ,
370+ TextEditText = completionItem . TextEditText ,
371+ AdditionalTextEdits = completionItem . AdditionalTextEdits ,
372+ CommitCharacters = completionItem . CommitCharacters ,
373+ Command = completionItem . Command ,
374+ Data = completionItem . Data ,
375+ Icon = completionItem . Icon ,
376+ Description = completionItem . Description ,
377+ VsCommitCharacters = completionItem . VsCommitCharacters ,
378+ VsResolveTextEditOnCommit = completionItem . VsResolveTextEditOnCommit ,
379+ } ;
380+ }
381+
382+ private static VSInternalCompletionItem CreateResolvedCompletionItem (
357383 VSInternalCompletionItem completionItem ,
358384 ClassifiedTextElement description ,
359- string detail ,
360385 string documentation )
361386 {
362- completionItem . Detail = detail ;
387+ var expectedCompletionItem = Clone ( completionItem ) ;
388+
363389 if ( documentation != null )
364390 {
365- completionItem . Documentation = new LSP . MarkupContent ( )
391+ expectedCompletionItem . Documentation = new MarkupContent ( )
366392 {
367393 Kind = LSP . MarkupKind . PlainText ,
368394 Value = documentation
369395 } ;
370396 }
371397
372- completionItem . Description = description ;
373- return completionItem ;
398+ expectedCompletionItem . Description = description ;
399+ return expectedCompletionItem ;
374400 }
375401
376402 private static ClassifiedTextRun [ ] CreateClassifiedTextRunForClass ( string className )
0 commit comments