mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 22:51:17 -05:00
Fixed string completions that require escaping (#55118)
This commit is contained in:
committed by
GitHub
parent
5b7b011518
commit
56accb08a1
@@ -32,6 +32,7 @@ import {
|
||||
endsWith,
|
||||
ensureTrailingDirectorySeparator,
|
||||
equateStringsCaseSensitive,
|
||||
escapeString,
|
||||
Extension,
|
||||
fileExtensionIsOneOf,
|
||||
filter,
|
||||
@@ -63,6 +64,7 @@ import {
|
||||
getSupportedExtensions,
|
||||
getSupportedExtensionsWithJsonIfResolveJsonModule,
|
||||
getTextOfJsxAttributeName,
|
||||
getTextOfNode,
|
||||
getTokenAtPosition,
|
||||
hasIndexSignature,
|
||||
hasProperty,
|
||||
@@ -262,8 +264,13 @@ function convertStringLiteralCompletions(
|
||||
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan, entries };
|
||||
}
|
||||
case StringLiteralCompletionKind.Types: {
|
||||
const quoteChar = contextToken.kind === SyntaxKind.NoSubstitutionTemplateLiteral
|
||||
? CharacterCodes.backtick
|
||||
: startsWith(getTextOfNode(contextToken), "'")
|
||||
? CharacterCodes.singleQuote
|
||||
: CharacterCodes.doubleQuote;
|
||||
const entries = completion.types.map(type => ({
|
||||
name: type.value,
|
||||
name: escapeString(type.value, quoteChar),
|
||||
kindModifiers: ScriptElementKindModifier.none,
|
||||
kind: ScriptElementKind.string,
|
||||
sortText: SortText.LocationPriority,
|
||||
|
||||
Reference in New Issue
Block a user