@@ -243,7 +243,8 @@ class oar(list):
243
243
var completions = await server . SendCompletion ( uri , 2 , 8 ) ;
244
244
245
245
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 ) ;
247
248
}
248
249
249
250
[ DataRow ( PythonLanguageVersion . V36 , "value" ) ]
@@ -259,7 +260,8 @@ class oar(list):
259
260
var completions = await server . SendCompletion ( uri , 2 , 8 ) ;
260
261
261
262
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 ) ;
263
265
}
264
266
265
267
[ ServerTestMethod ( LatestAvailable2X = true ) , Priority ( 0 ) ]
@@ -417,7 +419,8 @@ public async Task AddBracketsEnabled(Server server, string code, int row, int ch
417
419
var completion = await server . SendCompletion ( uri , row , character ) ;
418
420
419
421
completion . Should ( ) . HaveItem ( expectedLabel )
420
- . Which . Should ( ) . HaveInsertText ( expectedInsertText ) ;
422
+ . Which . Should ( ) . HaveInsertText ( expectedInsertText )
423
+ . And . HaveInsertTextFormat ( InsertTextFormat . Snippet ) ;
421
424
}
422
425
423
426
[ DataRow ( PythonLanguageMajorVersion . LatestV2 , "foo(self):{0} return super(B, self).foo()" ) ]
@@ -438,7 +441,8 @@ class B(A):
438
441
var completion = await server . SendCompletion ( uri , 6 , 9 ) ;
439
442
440
443
completion . Should ( ) . HaveItem ( "foo" )
441
- . Which . Should ( ) . HaveInsertText ( expectedInsertText ) ;
444
+ . Which . Should ( ) . HaveInsertText ( expectedInsertText )
445
+ . And . HaveInsertTextFormat ( InsertTextFormat . PlainText ) ;
442
446
}
443
447
444
448
[ TestMethod , Priority ( 0 ) ]
@@ -499,7 +503,8 @@ public async Task Completion_PackageRelativeImport(Server server) {
499
503
var completion = await server . SendCompletion ( uri , 0 , 22 ) ;
500
504
501
505
completion . Should ( ) . HaveItem ( "right" )
502
- . Which . Should ( ) . HaveInsertText ( "right" ) ;
506
+ . Which . Should ( ) . HaveInsertText ( "right" )
507
+ . And . HaveInsertTextFormat ( InsertTextFormat . PlainText ) ;
503
508
}
504
509
505
510
[ DataRow ( true ) ]
@@ -1008,7 +1013,7 @@ public async Task MultiPartDocument() {
1008
1013
public async Task WithWhitespaceAroundDot ( ) {
1009
1014
using ( var s = await CreateServerAsync ( ) ) {
1010
1015
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 ) ,
1012
1017
new CompletionContext { triggerCharacter = "." , triggerKind = CompletionTriggerKind . TriggerCharacter } ) ;
1013
1018
}
1014
1019
}
@@ -1029,7 +1034,7 @@ public async Task MarkupKindValid() {
1029
1034
}
1030
1035
}
1031
1036
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 ) {
1033
1038
await s . WaitForCompleteAnalysisAsync ( CancellationToken . None ) ;
1034
1039
var res = await s . Completion ( new CompletionParams {
1035
1040
textDocument = new TextDocumentIdentifier { uri = uri } ,
@@ -1040,10 +1045,14 @@ private static async Task AssertCompletion(Server s, Uri uri, IReadOnlyCollectio
1040
1045
DumpDetails ( res ) ;
1041
1046
1042
1047
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 ) > ( ) ;
1044
1049
1045
1050
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
+ }
1047
1056
}
1048
1057
1049
1058
if ( excludes != null && excludes . Any ( ) ) {
@@ -1119,4 +1128,4 @@ await s.DidOpenTextDocument(new DidOpenTextDocumentParams {
1119
1128
return uri ;
1120
1129
}
1121
1130
}
1122
- }
1131
+ }
0 commit comments