File tree Expand file tree Collapse file tree 5 files changed +36
-0
lines changed Expand file tree Collapse file tree 5 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,16 @@ namespace ts.SmartSelectionRange {
13
13
const prevNode : Node | undefined = children [ i - 1 ] ;
14
14
const node : Node = children [ i ] ;
15
15
const nextNode : Node | undefined = children [ i + 1 ] ;
16
+
16
17
if ( getTokenPosOfNode ( node , sourceFile , /*includeJsDoc*/ true ) > pos ) {
17
18
break outer;
18
19
}
19
20
21
+ const comment = singleOrUndefined ( getTrailingCommentRanges ( sourceFile . text , node . end ) ) ;
22
+ if ( comment && comment . kind === SyntaxKind . SingleLineCommentTrivia ) {
23
+ pushSelectionCommentRange ( comment . pos , comment . end ) ;
24
+ }
25
+
20
26
if ( positionShouldSnapToNode ( sourceFile , pos , node ) ) {
21
27
// 1. Blocks are effectively redundant with SyntaxLists.
22
28
// 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping
@@ -89,6 +95,16 @@ namespace ts.SmartSelectionRange {
89
95
}
90
96
}
91
97
}
98
+
99
+ function pushSelectionCommentRange ( start : number , end : number ) : void {
100
+ pushSelectionRange ( start , end ) ;
101
+
102
+ let pos = start ;
103
+ while ( sourceFile . text . charCodeAt ( pos ) === CharacterCodes . slash ) {
104
+ pos ++ ;
105
+ }
106
+ pushSelectionRange ( pos , end ) ;
107
+ }
92
108
}
93
109
94
110
/**
Original file line number Diff line number Diff line change
1
+ const a = 1; ///**/comment content
2
+
3
+ comment content
4
+ //comment content
5
+ const a = 1; //comment content
Original file line number Diff line number Diff line change
1
+ const a = 1; //a b/**/c d
2
+
3
+ a bc d
4
+ //a bc d
5
+ const a = 1; //a bc d
Original file line number Diff line number Diff line change
1
+ /// <reference path="fourslash.ts" />
2
+
3
+ ////const a = 1; ///**/comment content
4
+
5
+ verify . baselineSmartSelection ( ) ;
Original file line number Diff line number Diff line change
1
+ /// <reference path="fourslash.ts" />
2
+
3
+ ////const a = 1; //a b/**/c d
4
+
5
+ verify . baselineSmartSelection ( ) ;
You can’t perform that action at this time.
0 commit comments