File tree 2 files changed +10
-0
lines changed
2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ function selectedLineRanges(state: EditorState) {
113
113
for ( let r of state . selection . ranges ) {
114
114
let fromLine = state . doc . lineAt ( r . from )
115
115
let toLine = r . to <= fromLine . to ? fromLine : state . doc . lineAt ( r . to )
116
+ if ( toLine . from > fromLine . from && toLine . from == r . to )
117
+ toLine = r . to == fromLine . to + 1 ? fromLine : state . doc . lineAt ( r . to - 1 )
116
118
let last = ranges . length - 1
117
119
if ( last >= 0 && ranges [ last ] . to > fromLine . from ) ranges [ last ] . to = toLine . to
118
120
else ranges . push ( { from : fromLine . from + / ^ \s * / . exec ( fromLine . text ) ! [ 0 ] . length , to : toLine . to } )
Original file line number Diff line number Diff line change @@ -185,6 +185,14 @@ describe("comment", () => {
185
185
checkLine ( `on|e\nt|w|o\nth|ree` ,
186
186
`${ o } on|e\nt|w|o\nth|ree ${ c } ` )
187
187
} )
188
+
189
+ it ( "doesn't include lines that the selection stops at the start of" , ( ) => {
190
+ checkLine ( `|one\n|two` , `${ o } |one ${ c } \n|two` )
191
+ } )
192
+
193
+ it ( "does include lines with cursor selection at the start" , ( ) => {
194
+ checkLine ( `|one\ntwo` , `|${ o } one ${ c } \ntwo` )
195
+ } )
188
196
} )
189
197
}
190
198
You can’t perform that action at this time.
0 commit comments