Skip to content

Commit 0f5e037

Browse files
authored
pass isSingle quote preference when building string literal (#51968)
1 parent eb1e257 commit 0f5e037

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/services/completions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ function getExhaustiveCaseSnippets(
10531053
elements.push(factory.createNumericLiteral(type.value));
10541054
break;
10551055
case "string":
1056-
elements.push(factory.createStringLiteral(type.value));
1056+
elements.push(factory.createStringLiteral(type.value, quotePreference === QuotePreference.Single));
10571057
break;
10581058
}
10591059
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// Quote preferences.
4+
5+
// @newline: LF
6+
//// declare const p: 'A' | 'B' | 'C';
7+
////
8+
//// switch (p) {
9+
//// /*1*/
10+
//// }
11+
12+
verify.completions(
13+
{
14+
marker: "1",
15+
isNewIdentifierLocation: false,
16+
includes: [
17+
{
18+
name: `case 'A': ...`,
19+
source: completion.CompletionSource.SwitchCases,
20+
sortText: completion.SortText.GlobalsOrKeywords,
21+
insertText:
22+
`case 'A':
23+
case 'B':
24+
case 'C':`,
25+
},
26+
],
27+
preferences: {
28+
includeCompletionsWithInsertText: true,
29+
quotePreference: "single",
30+
},
31+
},
32+
);

0 commit comments

Comments
 (0)