@@ -1245,25 +1245,25 @@ namespace ts {
1245
1245
if ( onEmitNode !== noEmitNotification && ( ! isEmitNotificationEnabled || isEmitNotificationEnabled ( node ) ) ) {
1246
1246
return pipelineEmitWithNotification ;
1247
1247
}
1248
- // falls through
1248
+ // falls through
1249
1249
1250
1250
case PipelinePhase . Substitution :
1251
1251
if ( substituteNode !== noEmitSubstitution && ( lastSubstitution = substituteNode ( emitHint , node ) ) !== node ) {
1252
1252
return pipelineEmitWithSubstitution ;
1253
1253
}
1254
- // falls through
1254
+ // falls through
1255
1255
1256
1256
case PipelinePhase . Comments :
1257
1257
if ( ! commentsDisabled && node . kind !== SyntaxKind . SourceFile ) {
1258
1258
return pipelineEmitWithComments ;
1259
1259
}
1260
- // falls through
1260
+ // falls through
1261
1261
1262
1262
case PipelinePhase . SourceMaps :
1263
1263
if ( ! sourceMapsDisabled && node . kind !== SyntaxKind . SourceFile && ! isInJsonFile ( node ) ) {
1264
1264
return pipelineEmitWithSourceMap ;
1265
1265
}
1266
- // falls through
1266
+ // falls through
1267
1267
1268
1268
case PipelinePhase . Emit :
1269
1269
return pipelineEmitWithHint ;
@@ -4492,8 +4492,8 @@ namespace ts {
4492
4492
if ( preserveSourceNewlines ) {
4493
4493
return getEffectiveLines (
4494
4494
includeComments => getLinesBetweenRangeEndAndRangeStart (
4495
- getOriginalNode ( previousNode ) ,
4496
- getOriginalNode ( nextNode ) ,
4495
+ previousNode ,
4496
+ nextNode ,
4497
4497
currentSourceFile ! ,
4498
4498
includeComments ) ) ;
4499
4499
}
@@ -4510,25 +4510,30 @@ namespace ts {
4510
4510
}
4511
4511
4512
4512
function siblingNodePositionsAreComparable ( previousNode : Node , nextNode : Node ) {
4513
- if ( previousNode . kind === SyntaxKind . NotEmittedStatement && nextNode . kind === SyntaxKind . NotEmittedStatement ) {
4514
- return false ;
4515
- }
4516
- if ( nodeIsSynthesized ( previousNode ) || nodeIsSynthesized ( nextNode ) ) {
4513
+ if ( nodeIsSynthesized ( previousNode ) || nodeIsSynthesized ( nextNode ) || previousNode . parent !== nextNode . parent ) {
4517
4514
return false ;
4518
4515
}
4519
4516
4520
- // Get the position next node and compare against nextNode. If they are not equal, nodes have been rearranged and positions cannot be compared.
4521
- const originalNextNode = getNodeAtPosition ( currentSourceFile ! , previousNode . end + 1 ) ;
4522
- if ( originalNextNode . pos !== nextNode . pos ) {
4523
- return false ;
4524
- }
4517
+ if ( isImportSpecifier ( previousNode ) ) {
4518
+ const getNextSpecifier = ( node : ImportSpecifier ) : ImportSpecifier | undefined => {
4519
+ if ( ! node . parent ) {
4520
+ return ;
4521
+ }
4522
+ for ( const sibling of node . parent . elements ) {
4523
+ if ( node . pos < sibling . pos ) {
4524
+ return sibling ;
4525
+ }
4526
+ }
4527
+ } ;
4525
4528
4526
- if ( ! previousNode . parent || ! nextNode . parent ) {
4527
- const previousParent = getOriginalNode ( previousNode ) . parent ;
4528
- return previousParent && previousParent === getOriginalNode ( nextNode ) . parent ;
4529
+ // Get the next specifier and compare against nextNode. If they are not equal, nodes have been rearranged and positions cannot be compared.
4530
+ const nextSpecifier = getNextSpecifier ( previousNode ) ;
4531
+ if ( nextSpecifier && nextSpecifier !== nextNode ) {
4532
+ return false ;
4533
+ }
4529
4534
}
4530
4535
4531
- return nextNode . pos >= previousNode . end ;
4536
+ return true ;
4532
4537
}
4533
4538
4534
4539
function getClosingLineTerminatorCount ( parentNode : TextRange , children : readonly Node [ ] , format : ListFormat ) : number {
0 commit comments