@@ -25,19 +25,15 @@ export class SignatureHelpProvider implements vscode.SignatureHelpProvider {
25
25
document ,
26
26
position ,
27
27
token ,
28
- ) . then ( hover => {
29
- return this . hoverToSignatureHelp ( hover ) ;
30
- } ) ;
28
+ ) . then ( hover => this . hoverToSignatureHelp ( hover ) ) ;
31
29
} else if ( context . triggerCharacter === ',' ) {
32
- if ( this . previousFunctionPosition ) {
30
+ if ( this . previousFunctionPosition && position . line === this . previousFunctionPosition . line ) {
33
31
return this . provideHover (
34
32
this . languageClient ,
35
33
document ,
36
34
this . previousFunctionPosition ,
37
35
token ,
38
- ) . then ( hover => {
39
- return this . hoverToSignatureHelp ( hover ) ;
40
- } ) ;
36
+ ) . then ( hover => this . hoverToSignatureHelp ( hover ) ) ;
41
37
} else {
42
38
return null ;
43
39
}
@@ -64,12 +60,8 @@ export class SignatureHelpProvider implements vscode.SignatureHelpProvider {
64
60
) ,
65
61
token ,
66
62
) . then (
67
- data => {
68
- resolve ( lc . protocol2CodeConverter . asHover ( data ) ) ;
69
- } ,
70
- error => {
71
- reject ( error ) ;
72
- } ,
63
+ data => resolve ( lc . protocol2CodeConverter . asHover ( data ) ) ,
64
+ error => reject ( error ) ,
73
65
) ;
74
66
} ) ;
75
67
}
@@ -100,11 +92,11 @@ export class SignatureHelpProvider implements vscode.SignatureHelpProvider {
100
92
docs: Option<String>,
101
93
) -> Vec<MarkedString> {}
102
94
This means the first object is the type - function signature,
103
- but for the following, there is no way of certainly knowing which is the
95
+ but for the following, there is no way of certainly knowing which is the
104
96
function documentation that we want to display in the tooltip.
105
-
97
+
106
98
Assuming the context is never populated for a function definition (this might be wrong
107
- and needs further validation, but initial tests show it to hold true in most cases), and
99
+ and needs further validation, but initial tests show it to hold true in most cases), and
108
100
we also assume that most functions contain rather documentation, than just a URL without
109
101
any inline documentation, we check the length of contents, and we assume that if there are:
110
102
- two objects, they are the signature and docs, and docs is contents[1]
@@ -124,22 +116,7 @@ export class SignatureHelpProvider implements vscode.SignatureHelpProvider {
124
116
return undefined ;
125
117
}
126
118
127
- let doc : vscode . MarkdownString | undefined ;
128
- switch ( hover . contents . length ) {
129
- case 1 :
130
- doc = undefined ;
131
- break ;
132
- case 2 :
133
- doc = hover . contents [ 1 ] as vscode . MarkdownString ;
134
- break ;
135
- case 3 :
136
- doc = hover . contents [ 2 ] as vscode . MarkdownString ;
137
- break ;
138
- case 4 :
139
- doc = hover . contents [ 3 ] as vscode . MarkdownString ;
140
- break ;
141
- }
142
-
119
+ const doc = hover . contents . length > 1 ? hover . contents . slice ( - 1 ) [ 0 ] as vscode . MarkdownString : undefined ;
143
120
const si = new vscode . SignatureInformation ( label , doc ) ;
144
121
145
122
// without parsing the function definition, we don't have a way to get more info on parameters.
0 commit comments