@@ -17,7 +17,7 @@ namespace ts.SmartSelectionRange {
17
17
break outer;
18
18
}
19
19
20
- if ( positionShouldSnapToNode ( pos , node , nextNode ) ) {
20
+ if ( positionShouldSnapToNode ( sourceFile , pos , node ) ) {
21
21
// 1. Blocks are effectively redundant with SyntaxLists.
22
22
// 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping
23
23
// of things that should be considered independently.
@@ -97,12 +97,11 @@ namespace ts.SmartSelectionRange {
97
97
* count too, unless that position belongs to the next node. In effect, makes
98
98
* selections able to snap to preceding tokens when the cursor is on the tail
99
99
* end of them with only whitespace ahead.
100
+ * @param sourceFile The source file containing the nodes.
100
101
* @param pos The position to check.
101
102
* @param node The candidate node to snap to.
102
- * @param nextNode The next sibling node in the tree.
103
- * @param sourceFile The source file containing the nodes.
104
103
*/
105
- function positionShouldSnapToNode ( pos : number , node : Node , nextNode : Node | undefined ) {
104
+ function positionShouldSnapToNode ( sourceFile : SourceFile , pos : number , node : Node ) {
106
105
// Can’t use 'ts.positionBelongsToNode()' here because it cleverly accounts
107
106
// for missing nodes, which can’t really be considered when deciding what
108
107
// to select.
@@ -111,9 +110,8 @@ namespace ts.SmartSelectionRange {
111
110
return true ;
112
111
}
113
112
const nodeEnd = node . getEnd ( ) ;
114
- const nextNodeStart = nextNode && nextNode . getStart ( ) ;
115
113
if ( nodeEnd === pos ) {
116
- return pos !== nextNodeStart ;
114
+ return getTouchingPropertyName ( sourceFile , pos ) . pos < node . end ;
117
115
}
118
116
return false ;
119
117
}
0 commit comments