mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fix(36023): fix crash in document highlight service (#36233)
This commit is contained in:
committed by
Daniel Rosenwasser
parent
96e8fbc657
commit
ce4c4b6183
@@ -66,8 +66,12 @@ namespace ts {
|
||||
case SyntaxKind.SwitchKeyword:
|
||||
return useParent(node.parent, isSwitchStatement, getSwitchCaseDefaultOccurrences);
|
||||
case SyntaxKind.CaseKeyword:
|
||||
case SyntaxKind.DefaultKeyword:
|
||||
return useParent(node.parent.parent.parent, isSwitchStatement, getSwitchCaseDefaultOccurrences);
|
||||
case SyntaxKind.DefaultKeyword: {
|
||||
if (isDefaultClause(node.parent) || isCaseClause(node.parent)) {
|
||||
return useParent(node.parent.parent.parent, isSwitchStatement, getSwitchCaseDefaultOccurrences);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
case SyntaxKind.BreakKeyword:
|
||||
case SyntaxKind.ContinueKeyword:
|
||||
return useParent(node.parent, isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////[|case|]
|
||||
////[|default|]
|
||||
|
||||
const [defaultKeywordRange, caseKeywordRange] = test.ranges();
|
||||
verify.noDocumentHighlights(defaultKeywordRange);
|
||||
verify.noDocumentHighlights(caseKeywordRange);
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////const foo = 'foo';
|
||||
////[|switch|] (foo) {
|
||||
//// [|case|] 'foo':
|
||||
//// [|break|];
|
||||
//// [|default|]:
|
||||
//// [|break|];
|
||||
////}
|
||||
|
||||
const [r0, r1, r2, r3, r4] = test.ranges();
|
||||
verify.documentHighlightsOf(r1, [r0, r1, r2, r3, r4]);
|
||||
verify.documentHighlightsOf(r4, [r0, r1, r2, r3, r4]);
|
||||
Reference in New Issue
Block a user