Skip to content

Commit aebcb6d

Browse files
Merge pull request #29216 from uniqueiniquity/multilineArgumentSpans
Give appropriate outlining span for array and object literals as args in call expression
2 parents d3bcb82 + a266131 commit aebcb6d

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/services/outliningElementsCollector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ namespace ts.OutliningElementsCollector {
207207
}
208208

209209
function spanForObjectOrArrayLiteral(node: Node, open: SyntaxKind.OpenBraceToken | SyntaxKind.OpenBracketToken = SyntaxKind.OpenBraceToken): OutliningSpan | undefined {
210-
// If the block has no leading keywords and is inside an array literal,
210+
// If the block has no leading keywords and is inside an array literal or call expression,
211211
// we only want to collapse the span of the block.
212212
// Otherwise, the collapsed section will include the end of the previous line.
213-
return spanForNode(node, /*autoCollapse*/ false, /*useFullStart*/ !isArrayLiteralExpression(node.parent), open);
213+
return spanForNode(node, /*autoCollapse*/ false, /*useFullStart*/ !isArrayLiteralExpression(node.parent) && !isCallExpression(node.parent), open);
214214
}
215215

216216
function spanForNode(hintSpanNode: Node, autoCollapse = false, useFullStart = true, open: SyntaxKind.OpenBraceToken | SyntaxKind.OpenBracketToken = SyntaxKind.OpenBraceToken): OutliningSpan | undefined {

tests/cases/fourslash/getOutliningSpans.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,18 @@
102102
//////outline after a deeply nested node
103103
////class AfterNestedNodes[| {
104104
////}|]
105+
////// function arguments
106+
////function f(x: number[], y: number[])[| {
107+
//// return 3;
108+
////}|]
109+
////f(
110+
////// single line array literal span won't render in VS
111+
//// [|[0]|],
112+
//// [|[
113+
//// 1,
114+
//// 2
115+
//// ]|]
116+
////);
117+
105118

106119
verify.outliningSpansInCurrentFile(test.ranges(), "code");

0 commit comments

Comments
 (0)