@@ -42,17 +42,17 @@ suite('ParamHintCompletionProvider', () => {
42
42
assert . notEqual ( actual , null ) ;
43
43
assert . equal ( actual ?. items [ 0 ] . label . trim ( ) , PythonType . Int ) ;
44
44
} ) ;
45
-
46
- test ( "does not provide items for dict keys" , async ( ) => {
47
- let expected = null ;
48
- let actual = await providerResult ( provider , "):\n d = { key:" ) ;
49
- assert . equal ( actual , expected ) ;
45
+
46
+ test ( "does not provide items unless a function def is detected" , async ( ) => {
47
+ let text = " :" ;
48
+ let pos = new vsc . Position ( 0 , text . length ) ;
49
+ let actual = await provideCompletionItems ( provider , text , pos ) ;
50
+ assert . equal ( actual , null ) ;
50
51
} ) ;
51
52
52
53
test ( "does not provide items for ':' without a param (within function brackets)" , async ( ) => {
53
- let expected = null ;
54
54
let actual = await providerResult ( provider , "param, :" ) ;
55
- assert . equal ( actual , expected ) ;
55
+ assert . equal ( actual , null ) ;
56
56
} ) ;
57
57
58
58
test ( "does not provide items for ':' under a function def" , async ( ) => {
@@ -64,12 +64,15 @@ suite('ParamHintCompletionProvider', () => {
64
64
data = "):\n :" ;
65
65
actual = await providerResult ( provider , data ) ;
66
66
assert . equal ( actual , expected , messageFor ( { data, expected } , actual ) ) ;
67
+
68
+ data = "):\n d = { key:" ;
69
+ actual = await providerResult ( provider , data ) ;
70
+ assert . equal ( actual , null , messageFor ( { data, expected } , actual ) ) ;
67
71
} ) ;
68
72
69
73
test ( "does not provide items for end of function definition" , async ( ) => {
70
- let expected = null ;
71
74
let actual = await providerResult ( provider , "):" ) ;
72
- assert . equal ( actual , expected ) ;
75
+ assert . equal ( actual , null ) ;
73
76
} ) ;
74
77
75
78
test ( "does not include * in parameter name" , async ( ) => {
@@ -96,9 +99,17 @@ async function providerResult(
96
99
content += trailingText ;
97
100
}
98
101
99
- const doc = await vsc . workspace . openTextDocument ( { language, content } ) ;
102
+ return provideCompletionItems ( provider , content , lastPos ) ;
103
+ }
104
+
105
+ async function provideCompletionItems (
106
+ provider : CompletionProvider ,
107
+ documentContent : string ,
108
+ pos : vsc . Position
109
+ ) : Promise < vsc . CompletionList | null > {
110
+ const doc = await vsc . workspace . openTextDocument ( { language, content : documentContent } ) ;
100
111
const token = new vsc . CancellationTokenSource ( ) . token ;
101
112
const ctx = { triggerCharacter : paramHintTrigger , triggerKind : vsc . CompletionTriggerKind . TriggerCharacter } ;
102
113
103
- return provider . provideCompletionItems ( doc , lastPos , token , ctx ) ;
114
+ return provider . provideCompletionItems ( doc , pos , token , ctx ) ;
104
115
}
0 commit comments