File tree Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -4520,16 +4520,18 @@ namespace ts {
45204520 return false ;
45214521 }
45224522
4523+ // If nodes haven't been transformed, they should always be real siblings
4524+ if ( ! previousNode . original && ! nextNode . original ) {
4525+ return true ;
4526+ }
4527+
45234528 if ( ! previousNode . parent || ! nextNode . parent ) {
45244529 const previousParent = getOriginalNode ( previousNode ) . parent ;
45254530 return previousParent && previousParent === getOriginalNode ( nextNode ) . parent ;
45264531 }
45274532
4528- if ( ! nodeIsFirstNodeAtOrAfterPosition ( currentSourceFile ! , getOriginalNode ( nextNode ) , previousNode . end ) ) {
4529- return false ;
4530- }
4531-
4532- return true ;
4533+ // This check is most expensive, so everything preceding is avoiding it when possible
4534+ return nodeIsFirstNodeAtOrAfterPosition ( getOriginalNode ( nextNode ) , previousNode . end ) ;
45334535 }
45344536
45354537 function getClosingLineTerminatorCount ( parentNode : TextRange , children : readonly Node [ ] , format : ListFormat ) : number {
Original file line number Diff line number Diff line change @@ -7119,10 +7119,11 @@ namespace ts {
71197119 }
71207120 }
71217121
7122- export function nodeIsFirstNodeAtOrAfterPosition ( sourceFile : SourceFile , node : Node , position : number ) : boolean {
7122+ export function nodeIsFirstNodeAtOrAfterPosition ( node : Node , position : number ) : boolean {
71237123 if ( node . pos === position ) return true ;
71247124 if ( node . pos < position ) return false ;
7125- let current : Node = sourceFile ;
7125+ let current = findAncestor ( node . parent , p => textRangeContainsPositionInclusive ( p , position ) ) ;
7126+ if ( ! current ) return false ;
71267127 let next : Node | undefined ;
71277128 const getContainingChild = ( child : Node ) => {
71287129 if ( child . pos <= position && ( position < child . end || ( position === child . end && ( child . kind === SyntaxKind . EndOfFileToken ) ) ) ) {
@@ -7133,7 +7134,9 @@ namespace ts {
71337134 }
71347135 } ;
71357136 while ( true ) {
7136- const child = isSourceFileJS ( sourceFile ) && hasJSDocNodes ( current ) && forEach ( current . jsDoc , getContainingChild ) || forEachChild ( current , getContainingChild ) ;
7137+ const child : Node | undefined =
7138+ isInJSFile ( current ) && hasJSDocNodes ( current ) && forEach ( current . jsDoc , getContainingChild ) ||
7139+ forEachChild ( current , getContainingChild ) ;
71377140 if ( child === node || next === node ) {
71387141 return true ;
71397142 }
Original file line number Diff line number Diff line change @@ -1046,7 +1046,7 @@ namespace ts {
10461046 // All node tests in the following list should *not* reference parent pointers so that
10471047 // they may be used with transformations.
10481048 /* @internal */
1049- export function isNode ( node : Node ) {
1049+ export function isNode ( node : any ) : node is Node {
10501050 return isNodeKind ( node . kind ) ;
10511051 }
10521052
You can’t perform that action at this time.
0 commit comments