File tree 3 files changed +14
-9
lines changed
3 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -4520,16 +4520,18 @@ namespace ts {
4520
4520
return false ;
4521
4521
}
4522
4522
4523
+ // If nodes haven't been transformed, they should always be real siblings
4524
+ if ( ! previousNode . original && ! nextNode . original ) {
4525
+ return true ;
4526
+ }
4527
+
4523
4528
if ( ! previousNode . parent || ! nextNode . parent ) {
4524
4529
const previousParent = getOriginalNode ( previousNode ) . parent ;
4525
4530
return previousParent && previousParent === getOriginalNode ( nextNode ) . parent ;
4526
4531
}
4527
4532
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 ) ;
4533
4535
}
4534
4536
4535
4537
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 {
7119
7119
}
7120
7120
}
7121
7121
7122
- export function nodeIsFirstNodeAtOrAfterPosition ( sourceFile : SourceFile , node : Node , position : number ) : boolean {
7122
+ export function nodeIsFirstNodeAtOrAfterPosition ( node : Node , position : number ) : boolean {
7123
7123
if ( node . pos === position ) return true ;
7124
7124
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 ;
7126
7127
let next : Node | undefined ;
7127
7128
const getContainingChild = ( child : Node ) => {
7128
7129
if ( child . pos <= position && ( position < child . end || ( position === child . end && ( child . kind === SyntaxKind . EndOfFileToken ) ) ) ) {
@@ -7133,7 +7134,9 @@ namespace ts {
7133
7134
}
7134
7135
} ;
7135
7136
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 ) ;
7137
7140
if ( child === node || next === node ) {
7138
7141
return true ;
7139
7142
}
Original file line number Diff line number Diff line change @@ -1046,7 +1046,7 @@ namespace ts {
1046
1046
// All node tests in the following list should *not* reference parent pointers so that
1047
1047
// they may be used with transformations.
1048
1048
/* @internal */
1049
- export function isNode ( node : Node ) {
1049
+ export function isNode ( node : any ) : node is Node {
1050
1050
return isNodeKind ( node . kind ) ;
1051
1051
}
1052
1052
You can’t perform that action at this time.
0 commit comments