@@ -451,20 +451,8 @@ export namespace SmartIndenter {
451451 // ? 1 : ( L1: whenTrue indented because it's on a new line
452452 // 0 L2: indented two stops, one because whenTrue was indented
453453 // ); and one because of the parentheses spanning multiple lines
454-
455- // However, when condition and whenTrue are on the same line, whenFalse should not be indented:
456- //
457- // const z =
458- // 0 ? 1 : L1: whenTrue indented because it's on a new line
459- // 2 ? 3 : L2: not indented
460- // 4; L3: not indented
461454 const trueStartLine = getStartLineAndCharacterForNode ( parent . whenTrue , sourceFile ) . line ;
462455 const trueEndLine = getLineAndCharacterOfPosition ( sourceFile , parent . whenTrue . end ) . line ;
463-
464- if ( conditionEndLine === trueStartLine && trueStartLine === trueEndLine && trueEndLine !== childStartLine ) {
465- return true ;
466- }
467-
468456 return conditionEndLine === trueStartLine && trueEndLine === childStartLine ;
469457 }
470458 }
@@ -709,8 +697,9 @@ export namespace SmartIndenter {
709697 break ;
710698 case SyntaxKind . ConditionalExpression :
711699 if ( child && sourceFile ) {
712- const childStartCharacter = sourceFile . getLineAndCharacterOfPosition ( skipTrivia ( sourceFile . text , child . pos ) ) . character ;
713- if ( ! rangeIsOnOneLine ( sourceFile , parent ) && childStartCharacter !== SyntaxKind . QuestionToken ) {
700+ const childStartLine = sourceFile . getLineAndCharacterOfPosition ( skipTrivia ( sourceFile . text , child . pos ) ) . line ;
701+ const childEndLine = sourceFile . getLineAndCharacterOfPosition ( skipTrivia ( sourceFile . text , child . end ) ) . line ;
702+ if ( ! rangeIsOnOneLine ( sourceFile , parent ) && childStartLine !== childEndLine && childKind !== SyntaxKind . ParenthesizedExpression ) {
714703 return false ;
715704 }
716705 }
0 commit comments