Fix incorrectly looking for position in call/new expression arguments when looking for indentation of type arguments

Fixes #32487
This commit is contained in:
Sheetal Nandi
2019-10-28 12:34:06 -07:00
parent 634e0ad52b
commit 2e435ae3b0
2 changed files with 21 additions and 2 deletions
+3 -2
View File
@@ -326,8 +326,9 @@ namespace ts.formatting {
export function argumentStartsOnSameLineAsPreviousArgument(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean {
if (isCallOrNewExpression(parent)) {
if (!parent.arguments) return false;
const currentNode = Debug.assertDefined(find(parent.arguments, arg => arg.pos === child.pos));
const currentNode = find(parent.arguments, arg => arg.pos === child.pos);
// If its not one of the argument, dont look past this
if (!currentNode) return false;
const currentIndex = parent.arguments.indexOf(currentNode);
if (currentIndex === 0) return false; // Can't look at previous node if first
@@ -0,0 +1,18 @@
/// <reference path="fourslash.ts"/>
////const genericObject = new GenericObject<
//// /*1*/{}
////>();
////const genericObject2 = new GenericObject2<
//// /*2*/{},
//// /*3*/{}
////>();
format.document();
goTo.marker("1");
verify.currentLineContentIs(" {}");
goTo.marker("2");
verify.currentLineContentIs(" {},");
goTo.marker("3");
verify.currentLineContentIs(" {}");