mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix incorrectly looking for position in call/new expression arguments when looking for indentation of type arguments
Fixes #32487
This commit is contained in:
@@ -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(" {}");
|
||||
Reference in New Issue
Block a user