Merge pull request #29216 from uniqueiniquity/multilineArgumentSpans

Give appropriate outlining span for array and object literals as args in call expression
This commit is contained in:
Benjamin Lichtman 2018-12-31 15:18:07 -08:00 committed by GitHub
commit aebcb6df36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

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

View File

@ -102,5 +102,18 @@
//////outline after a deeply nested node
////class AfterNestedNodes[| {
////}|]
////// function arguments
////function f(x: number[], y: number[])[| {
//// return 3;
////}|]
////f(
////// single line array literal span won't render in VS
//// [|[0]|],
//// [|[
//// 1,
//// 2
//// ]|]
////);
verify.outliningSpansInCurrentFile(test.ranges(), "code");