@@ -243,7 +243,8 @@ class oar(list):
243243 var completions = await server . SendCompletion ( uri , 2 , 8 ) ;
244244
245245 completions . Should ( ) . HaveItem ( "append" )
246- . Which . Should ( ) . HaveInsertText ( $ "append(self, value):{ Environment . NewLine } return super(oar, self).append(value)") ;
246+ . Which . Should ( ) . HaveInsertText ( $ "append(self, value):{ Environment . NewLine } return super(oar, self).append(value)")
247+ . And . HaveInsertTextFormat ( InsertTextFormat . PlainText ) ;
247248 }
248249
249250 [ DataRow ( PythonLanguageVersion . V36 , "value" ) ]
@@ -259,7 +260,8 @@ class oar(list):
259260 var completions = await server . SendCompletion ( uri , 2 , 8 ) ;
260261
261262 completions . Should ( ) . HaveItem ( "append" )
262- . Which . Should ( ) . HaveInsertText ( $ "append(self, { parameterName } ):{ Environment . NewLine } return super().append({ parameterName } )") ;
263+ . Which . Should ( ) . HaveInsertText ( $ "append(self, { parameterName } ):{ Environment . NewLine } return super().append({ parameterName } )")
264+ . And . HaveInsertTextFormat ( InsertTextFormat . PlainText ) ;
263265 }
264266
265267 [ ServerTestMethod ( LatestAvailable2X = true ) , Priority ( 0 ) ]
@@ -417,7 +419,8 @@ public async Task AddBracketsEnabled(Server server, string code, int row, int ch
417419 var completion = await server . SendCompletion ( uri , row , character ) ;
418420
419421 completion . Should ( ) . HaveItem ( expectedLabel )
420- . Which . Should ( ) . HaveInsertText ( expectedInsertText ) ;
422+ . Which . Should ( ) . HaveInsertText ( expectedInsertText )
423+ . And . HaveInsertTextFormat ( InsertTextFormat . Snippet ) ;
421424 }
422425
423426 [ DataRow ( PythonLanguageMajorVersion . LatestV2 , "foo(self):{0} return super(B, self).foo()" ) ]
@@ -438,7 +441,8 @@ class B(A):
438441 var completion = await server . SendCompletion ( uri , 6 , 9 ) ;
439442
440443 completion . Should ( ) . HaveItem ( "foo" )
441- . Which . Should ( ) . HaveInsertText ( expectedInsertText ) ;
444+ . Which . Should ( ) . HaveInsertText ( expectedInsertText )
445+ . And . HaveInsertTextFormat ( InsertTextFormat . PlainText ) ;
442446 }
443447
444448 [ TestMethod , Priority ( 0 ) ]
@@ -499,7 +503,8 @@ public async Task Completion_PackageRelativeImport(Server server) {
499503 var completion = await server . SendCompletion ( uri , 0 , 22 ) ;
500504
501505 completion . Should ( ) . HaveItem ( "right" )
502- . Which . Should ( ) . HaveInsertText ( "right" ) ;
506+ . Which . Should ( ) . HaveInsertText ( "right" )
507+ . And . HaveInsertTextFormat ( InsertTextFormat . PlainText ) ;
503508 }
504509
505510 [ DataRow ( true ) ]
@@ -1008,7 +1013,7 @@ public async Task MultiPartDocument() {
10081013 public async Task WithWhitespaceAroundDot ( ) {
10091014 using ( var s = await CreateServerAsync ( ) ) {
10101015 var u = await s . OpenDefaultDocumentAndGetUriAsync ( "import sys\n sys . version\n " ) ;
1011- await AssertCompletion ( s , u , new [ ] { "argv" } , null , new SourceLocation ( 2 , 7 ) ,
1016+ await AssertCompletion ( s , u , new [ ] { "argv" } , null , new SourceLocation ( 2 , 7 ) ,
10121017 new CompletionContext { triggerCharacter = "." , triggerKind = CompletionTriggerKind . TriggerCharacter } ) ;
10131018 }
10141019 }
@@ -1029,7 +1034,7 @@ public async Task MarkupKindValid() {
10291034 }
10301035 }
10311036
1032- private static async Task AssertCompletion ( Server s , Uri uri , IReadOnlyCollection < string > contains , IReadOnlyCollection < string > excludes , Position ? position = null , CompletionContext ? context = null , Func < CompletionItem , string > cmpKey = null , string expr = null , Range ? applicableSpan = null ) {
1037+ private static async Task AssertCompletion ( Server s , Uri uri , IReadOnlyCollection < string > contains , IReadOnlyCollection < string > excludes , Position ? position = null , CompletionContext ? context = null , Func < CompletionItem , string > cmpKey = null , string expr = null , Range ? applicableSpan = null , InsertTextFormat ? allFormat = InsertTextFormat . PlainText ) {
10331038 await s . WaitForCompleteAnalysisAsync ( CancellationToken . None ) ;
10341039 var res = await s . Completion ( new CompletionParams {
10351040 textDocument = new TextDocumentIdentifier { uri = uri } ,
@@ -1040,10 +1045,14 @@ private static async Task AssertCompletion(Server s, Uri uri, IReadOnlyCollectio
10401045 DumpDetails ( res ) ;
10411046
10421047 cmpKey = cmpKey ?? ( c => c . insertText ) ;
1043- var items = res . items ? . Select ( cmpKey ) . ToList ( ) ?? new List < string > ( ) ;
1048+ var items = res . items ? . Select ( i => ( cmpKey ( i ) , i . insertTextFormat ) ) . ToList ( ) ?? new List < ( string , InsertTextFormat ) > ( ) ;
10441049
10451050 if ( contains != null && contains . Any ( ) ) {
1046- items . Should ( ) . Contain ( contains ) ;
1051+ items . Select ( i => i . Item1 ) . Should ( ) . Contain ( contains ) ;
1052+
1053+ if ( allFormat != null ) {
1054+ items . Where ( i => contains . Contains ( i . Item1 ) ) . Select ( i => i . Item2 ) . Should ( ) . AllBeEquivalentTo ( allFormat ) ;
1055+ }
10471056 }
10481057
10491058 if ( excludes != null && excludes . Any ( ) ) {
@@ -1119,4 +1128,4 @@ await s.DidOpenTextDocument(new DidOpenTextDocumentParams {
11191128 return uri ;
11201129 }
11211130 }
1122- }
1131+ }
0 commit comments