File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,9 @@ export default class BlockSortFormattingProvider
121121 ) : Range {
122122 if ( ! this . isAttached ( document ) ) this . attachDocument ( document , token ) ;
123123 const blockSort = this . blockSortProviders . get ( document . uri ) ! ;
124- const initialRange = "start" in selection ? selection : new Range ( selection , selection ) ;
124+ const initialRange = blockSort . trimRange (
125+ "start" in selection ? selection : new Range ( selection , selection )
126+ ) ;
125127
126128 if ( options . expandSelection === false ) return initialRange ;
127129
Original file line number Diff line number Diff line change @@ -338,6 +338,9 @@ export default class BlockSortProvider implements Disposable {
338338 let start = selection . start . line ;
339339 let end = selection . end . line ;
340340
341+ if ( start < end && selection . start . character >= this . document . lineAt ( start ) . text . length ) start ++ ;
342+ if ( end > start && selection . end . character === 0 ) end -- ;
343+
341344 while ( start < end && this . document . lineAt ( start ) . isEmptyOrWhitespace ) start ++ ;
342345 while ( end > start && this . document . lineAt ( end ) . isEmptyOrWhitespace ) end -- ;
343346
You can’t perform that action at this time.
0 commit comments