From db0a9146b1f854daa62520d2ddb131da196ec17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sun, 10 Aug 2025 00:54:34 +0200 Subject: [PATCH] Add missing whitespace after type parameter's modifiers in interactive inlay hints --- src/services/inlayHints.ts | 2 + ...inlayHintsTypeParameterModifiers1.baseline | 77 +++++++++++++++++++ .../inlayHintsTypeParameterModifiers1.ts | 10 +++ 3 files changed, 89 insertions(+) create mode 100644 tests/baselines/reference/inlayHintsTypeParameterModifiers1.baseline create mode 100644 tests/cases/fourslash/inlayHintsTypeParameterModifiers1.ts diff --git a/src/services/inlayHints.ts b/src/services/inlayHints.ts index 8f01d1f067428..43dad7ea1793d 100644 --- a/src/services/inlayHints.ts +++ b/src/services/inlayHints.ts @@ -582,6 +582,7 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] { Debug.assertNode(node, isTypeParameterDeclaration); if (node.modifiers) { visitDisplayPartList(node.modifiers, " "); + parts.push({ text: " " }); } visitForDisplayParts(node.name); if (node.constraint) { @@ -597,6 +598,7 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] { Debug.assertNode(node, isParameter); if (node.modifiers) { visitDisplayPartList(node.modifiers, " "); + parts.push({ text: " " }); } if (node.dotDotDotToken) { parts.push({ text: "..." }); diff --git a/tests/baselines/reference/inlayHintsTypeParameterModifiers1.baseline b/tests/baselines/reference/inlayHintsTypeParameterModifiers1.baseline new file mode 100644 index 0000000000000..238677cbbb8f2 --- /dev/null +++ b/tests/baselines/reference/inlayHintsTypeParameterModifiers1.baseline @@ -0,0 +1,77 @@ +// === Inlay Hints === +function test1() { + ^ +{ + "text": "", + "displayParts": [ + { + "text": ": " + }, + { + "text": "<" + }, + { + "text": "const" + }, + { + "text": " " + }, + { + "text": "T", + "span": { + "start": 44, + "length": 1 + }, + "file": "/tests/cases/fourslash/inlayHintsTypeParameterModifiers1.ts" + }, + { + "text": ">" + }, + { + "text": "(" + }, + { + "text": "a" + }, + { + "text": ": " + }, + { + "text": "T", + "span": { + "start": 44, + "length": 1 + }, + "file": "/tests/cases/fourslash/inlayHintsTypeParameterModifiers1.ts" + }, + { + "text": ")" + }, + { + "text": " => " + }, + { + "text": "void" + } + ], + "position": 16, + "kind": "Type", + "whitespaceBefore": true +} + + return function (a: T) {}; + ^ +{ + "text": "", + "displayParts": [ + { + "text": ": " + }, + { + "text": "void" + } + ], + "position": 52, + "kind": "Type", + "whitespaceBefore": true +} \ No newline at end of file diff --git a/tests/cases/fourslash/inlayHintsTypeParameterModifiers1.ts b/tests/cases/fourslash/inlayHintsTypeParameterModifiers1.ts new file mode 100644 index 0000000000000..f537a91112d08 --- /dev/null +++ b/tests/cases/fourslash/inlayHintsTypeParameterModifiers1.ts @@ -0,0 +1,10 @@ +/// + +//// function test1() { +//// return function (a: T) {}; +//// } + +verify.baselineInlayHints(undefined, { + interactiveInlayHints: true, + includeInlayFunctionLikeReturnTypeHints: true, +});