Skip to content

Commit 0099e42

Browse files
authored
fix(55374): Invalid Parameter Inlay Hint (microsoft#55384)
1 parent 8863e2f commit 0099e42

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

src/services/inlayHints.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,13 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
247247
return;
248248
}
249249

250-
let signatureParamPos = 0;
251250
const sourceFile = shouldUseInteractiveInlayHints(preferences) ? expr.getSourceFile() : undefined;
251+
252+
let signatureParamPos = 0;
252253
for (const originalArg of args) {
253254
const arg = skipParentheses(originalArg);
254255
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
256+
signatureParamPos++;
255257
continue;
256258
}
257259

tests/baselines/reference/inlayHintsParameterNames.baseline

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,20 @@
2525
"whitespaceAfter": true
2626
}
2727

28+
foo3({}, 1);
29+
^
30+
{
31+
"text": "b:",
32+
"position": 161,
33+
"kind": "Parameter",
34+
"whitespaceAfter": true
35+
}
36+
2837
const C1 = class extends foo3(1) { }
2938
^
3039
{
3140
"text": "a:",
32-
"position": 180,
41+
"position": 229,
3342
"kind": "Parameter",
3443
"whitespaceAfter": true
3544
}
@@ -38,7 +47,7 @@ class C2 extends foo3(1) { }
3847
^
3948
{
4049
"text": "a:",
41-
"position": 209,
50+
"position": 258,
4251
"kind": "Parameter",
4352
"whitespaceAfter": true
4453
}
@@ -47,7 +56,7 @@ foo4(1, +1, -1, +"1");
4756
^
4857
{
4958
"text": "a:",
50-
"position": 282,
59+
"position": 331,
5160
"kind": "Parameter",
5261
"whitespaceAfter": true
5362
}
@@ -56,7 +65,7 @@ foo4(1, +1, -1, +"1");
5665
^
5766
{
5867
"text": "b:",
59-
"position": 285,
68+
"position": 334,
6069
"kind": "Parameter",
6170
"whitespaceAfter": true
6271
}
@@ -65,7 +74,7 @@ foo4(1, +1, -1, +"1");
6574
^
6675
{
6776
"text": "c:",
68-
"position": 289,
77+
"position": 338,
6978
"kind": "Parameter",
7079
"whitespaceAfter": true
7180
}
@@ -74,7 +83,7 @@ foo4(1, +1, -1, +"1");
7483
^
7584
{
7685
"text": "d:",
77-
"position": 293,
86+
"position": 342,
7887
"kind": "Parameter",
7988
"whitespaceAfter": true
8089
}
@@ -83,7 +92,7 @@ foo4(1, +1, -1, +"1");
8392
^
8493
{
8594
"text": "a:",
86-
"position": 484,
95+
"position": 533,
8796
"kind": "Parameter",
8897
"whitespaceAfter": true
8998
}
@@ -92,7 +101,7 @@ foo4(1, +1, -1, +"1");
92101
^
93102
{
94103
"text": "b:",
95-
"position": 497,
104+
"position": 546,
96105
"kind": "Parameter",
97106
"whitespaceAfter": true
98107
}
@@ -101,7 +110,7 @@ foo4(1, +1, -1, +"1");
101110
^
102111
{
103112
"text": "c:",
104-
"position": 512,
113+
"position": 561,
105114
"kind": "Parameter",
106115
"whitespaceAfter": true
107116
}
@@ -110,7 +119,7 @@ foo4(1, +1, -1, +"1");
110119
^
111120
{
112121
"text": "d:",
113-
"position": 522,
122+
"position": 571,
114123
"kind": "Parameter",
115124
"whitespaceAfter": true
116125
}
@@ -119,7 +128,7 @@ foo4(1, +1, -1, +"1");
119128
^
120129
{
121130
"text": "e:",
122-
"position": 532,
131+
"position": 581,
123132
"kind": "Parameter",
124133
"whitespaceAfter": true
125134
}
@@ -128,7 +137,7 @@ foo4(1, +1, -1, +"1");
128137
^
129138
{
130139
"text": "f:",
131-
"position": 543,
140+
"position": 592,
132141
"kind": "Parameter",
133142
"whitespaceAfter": true
134143
}
@@ -137,7 +146,7 @@ foo4(1, +1, -1, +"1");
137146
^
138147
{
139148
"text": "g:",
140-
"position": 557,
149+
"position": 606,
141150
"kind": "Parameter",
142151
"whitespaceAfter": true
143152
}
@@ -146,7 +155,7 @@ foo4(1, +1, -1, +"1");
146155
^
147156
{
148157
"text": "h:",
149-
"position": 572,
158+
"position": 621,
150159
"kind": "Parameter",
151160
"whitespaceAfter": true
152161
}
@@ -155,7 +164,7 @@ foo4(1, +1, -1, +"1");
155164
^
156165
{
157166
"text": "i:",
158-
"position": 581,
167+
"position": 630,
159168
"kind": "Parameter",
160169
"whitespaceAfter": true
161170
}
@@ -164,7 +173,7 @@ foo4(1, +1, -1, +"1");
164173
^
165174
{
166175
"text": "j:",
167-
"position": 595,
176+
"position": 644,
168177
"kind": "Parameter",
169178
"whitespaceAfter": true
170179
}
@@ -173,7 +182,7 @@ trace(`${1}`);
173182
^
174183
{
175184
"text": "message:",
176-
"position": 694,
185+
"position": 743,
177186
"kind": "Parameter",
178187
"whitespaceAfter": true
179188
}
@@ -182,7 +191,7 @@ trace(``);
182191
^
183192
{
184193
"text": "message:",
185-
"position": 709,
194+
"position": 758,
186195
"kind": "Parameter",
187196
"whitespaceAfter": true
188197
}

tests/cases/fourslash/inlayHintsParameterNames.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
//// function foo2 (a: number, { c }: any) {}
77
//// foo2(1, { c: 1 });
88

9+
////function foo3(a: any, b: number) {}
10+
////foo3({}, 1);
11+
912
////const foo3 = (a = 1) => class { }
1013
////const C1 = class extends foo3(1) { }
1114
////class C2 extends foo3(1) { }

0 commit comments

Comments
 (0)