mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
fix(55946): Errant case causes crash in switch/case snippet completions (#55949)
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
This commit is contained in:
parent
c640c5de0a
commit
f2805dc88b
@ -2824,7 +2824,7 @@ export function getCompletionEntryDetails(
|
||||
return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), ScriptElementKind.string, typeof literal === "string" ? SymbolDisplayPartKind.stringLiteral : SymbolDisplayPartKind.numericLiteral);
|
||||
}
|
||||
case "cases": {
|
||||
const { entry, importAdder } = getExhaustiveCaseSnippets(
|
||||
const snippets = getExhaustiveCaseSnippets(
|
||||
contextToken!.parent as CaseBlock,
|
||||
sourceFile,
|
||||
preferences,
|
||||
@ -2832,8 +2832,10 @@ export function getCompletionEntryDetails(
|
||||
host,
|
||||
program,
|
||||
/*formatContext*/ undefined,
|
||||
)!;
|
||||
if (importAdder.hasFixes()) {
|
||||
);
|
||||
|
||||
if (snippets?.importAdder.hasFixes()) {
|
||||
const { entry, importAdder } = snippets;
|
||||
const changes = textChanges.ChangeTracker.with(
|
||||
{ host, formatContext, preferences },
|
||||
importAdder.writeFixes,
|
||||
@ -2850,8 +2852,9 @@ export function getCompletionEntryDetails(
|
||||
}],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
name: entry.name,
|
||||
name,
|
||||
kind: ScriptElementKind.unknown,
|
||||
kindModifiers: "",
|
||||
displayParts: [],
|
||||
|
||||
3550
tests/baselines/reference/exhaustiveCaseCompletions9.baseline
Normal file
3550
tests/baselines/reference/exhaustiveCaseCompletions9.baseline
Normal file
File diff suppressed because it is too large
Load Diff
11
tests/cases/fourslash/exhaustiveCaseCompletions9.ts
Normal file
11
tests/cases/fourslash/exhaustiveCaseCompletions9.ts
Normal file
@ -0,0 +1,11 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @newline: LF
|
||||
////switch (Math.random() ? 123 : 456) {
|
||||
//// case "foo!":
|
||||
//// case/**/
|
||||
////}
|
||||
|
||||
verify.baselineCompletions({
|
||||
includeCompletionsWithInsertText: true,
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user