Skip to content

Commit 1663d01

Browse files
Fix outlining of objects in array
1 parent e1ba65a commit 1663d01

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/services/outliningElementsCollector.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ namespace ts.OutliningElementsCollector {
1616
}
1717
}
1818

19+
function addOutliningForObjectLiteralsInArray(startElement: Node, endElement: Node, autoCollapse: boolean) {
20+
if (startElement && endElement) {
21+
const span: OutliningSpan = {
22+
textSpan: createTextSpanFromBounds(startElement.getStart(), endElement.end),
23+
hintSpan: createTextSpanFromBounds(startElement.getStart(), endElement.end),
24+
bannerText: collapseText,
25+
autoCollapse
26+
};
27+
elements.push(span);
28+
}
29+
}
30+
1931
function addOutliningSpanComments(commentSpan: CommentRange, autoCollapse: boolean) {
2032
if (commentSpan) {
2133
const span: OutliningSpan = {
@@ -161,6 +173,10 @@ namespace ts.OutliningElementsCollector {
161173
case SyntaxKind.CaseBlock: {
162174
const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
163175
const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
176+
if (n.kind === SyntaxKind.ObjectLiteralExpression && n.parent.kind === SyntaxKind.ArrayLiteralExpression) {
177+
addOutliningForObjectLiteralsInArray(openBrace, closeBrace, autoCollapse(n));
178+
break;
179+
}
164180
addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n));
165181
break;
166182
}

0 commit comments

Comments
 (0)