mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
fix(52543): Module specifier should be escaped for snippet in import statement completion (#52574)
This commit is contained in:
parent
4ec9b2f8d7
commit
e7dfe82cc5
@ -2045,7 +2045,7 @@ function completionEntryDataToSymbolOriginInfo(data: CompletionEntryData, comple
|
||||
|
||||
function getInsertTextAndReplacementSpanForImportCompletion(name: string, importStatementCompletion: ImportStatementCompletionInfo, origin: SymbolOriginInfoResolvedExport, useSemicolons: boolean, sourceFile: SourceFile, options: CompilerOptions, preferences: UserPreferences) {
|
||||
const replacementSpan = importStatementCompletion.replacementSpan;
|
||||
const quotedModuleSpecifier = quote(sourceFile, preferences, origin.moduleSpecifier);
|
||||
const quotedModuleSpecifier = quote(sourceFile, preferences, escapeSnippetText(origin.moduleSpecifier));
|
||||
const exportKind =
|
||||
origin.isDefaultExport ? ExportKind.Default :
|
||||
origin.exportName === InternalSymbolName.ExportEquals ? ExportKind.ExportEquals :
|
||||
|
||||
106
tests/baselines/reference/importStatementCompletions3.baseline
Normal file
106
tests/baselines/reference/importStatementCompletions3.baseline
Normal file
@ -0,0 +1,106 @@
|
||||
=== /tests/cases/fourslash/./bar.ts ===
|
||||
// import f
|
||||
// ^
|
||||
// | ----------------------------------------------------------------------
|
||||
// | function foo(): void
|
||||
// | type
|
||||
// | ----------------------------------------------------------------------
|
||||
|
||||
[
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/./bar.ts",
|
||||
"position": 8,
|
||||
"name": ""
|
||||
},
|
||||
"item": {
|
||||
"flags": 11,
|
||||
"isGlobalCompletion": false,
|
||||
"isMemberCompletion": false,
|
||||
"isNewIdentifierLocation": true,
|
||||
"optionalReplacementSpan": {
|
||||
"start": 7,
|
||||
"length": 1
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"name": "foo",
|
||||
"kind": "function",
|
||||
"kindModifiers": "export",
|
||||
"sortText": "11",
|
||||
"source": [
|
||||
{
|
||||
"text": "./$foo",
|
||||
"kind": "text"
|
||||
}
|
||||
],
|
||||
"insertText": "import { foo$1 } from \"./\\\\$foo\";",
|
||||
"replacementSpan": {
|
||||
"start": 0,
|
||||
"length": 8
|
||||
},
|
||||
"sourceDisplay": [
|
||||
{
|
||||
"text": "./$foo",
|
||||
"kind": "text"
|
||||
}
|
||||
],
|
||||
"isSnippet": true,
|
||||
"isImportStatementCompletion": true,
|
||||
"data": {
|
||||
"exportName": "foo",
|
||||
"moduleSpecifier": "./$foo",
|
||||
"fileName": "/tests/cases/fourslash/$foo.ts"
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "function",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "foo",
|
||||
"kind": "functionName"
|
||||
},
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "void",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": []
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
14
tests/cases/fourslash/importStatementCompletions3.ts
Normal file
14
tests/cases/fourslash/importStatementCompletions3.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: ./$foo.ts
|
||||
////export function foo() {}
|
||||
|
||||
// @Filename: ./bar.ts
|
||||
////import f/**/
|
||||
|
||||
verify.baselineCompletions({
|
||||
includeCompletionsForImportStatements: true,
|
||||
includeCompletionsForModuleExports: true,
|
||||
includeCompletionsWithSnippetText: true,
|
||||
includeCompletionsWithInsertText: true
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user