Cherry-pick PR #34779 into release-3.7 (#34782)

Component commits:
2e435ae3b0 Fix incorrectly looking for position in call/new expression arguments when looking for indentation of type arguments Fixes #32487

0bb1b40b1b Update src/services/formatting/smartIndenter.ts
Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
TypeScript Bot
2019-10-28 14:59:27 -07:00
committed by Sheetal Nandi
parent 0965fc53a1
commit 17bd75d613
2 changed files with 21 additions and 2 deletions

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 it's not one of the arguments, don't 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

View File

@@ -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(" {}");