@@ -453,6 +453,7 @@ public void GetLinesShape(int startLine, float startCharX, int endLine, float en
453453 {
454454 LineInfo line1 = _lines [ startLine ] ;
455455 LineInfo line2 = _lines [ endLine ] ;
456+ bool leftAlign = _textFormat . align == AlignType . Left ;
456457 if ( startLine == endLine )
457458 {
458459 Rect r = Rect . MinMaxRect ( startCharX , line1 . y , endCharX , line1 . y + line1 . height ) ;
@@ -463,7 +464,7 @@ public void GetLinesShape(int startLine, float startCharX, int endLine, float en
463464 }
464465 else if ( startLine == endLine - 1 )
465466 {
466- Rect r = Rect . MinMaxRect ( startCharX , line1 . y , GUTTER_X + line1 . width , line1 . y + line1 . height ) ;
467+ Rect r = Rect . MinMaxRect ( startCharX , line1 . y , leftAlign ? ( GUTTER_X + line1 . width ) : _contentRect . xMax , line1 . y + line1 . height ) ;
467468 if ( clipped )
468469 resultRects . Add ( ToolSet . Intersection ( ref r , ref _contentRect ) ) ;
469470 else
@@ -476,15 +477,15 @@ public void GetLinesShape(int startLine, float startCharX, int endLine, float en
476477 }
477478 else
478479 {
479- Rect r = Rect . MinMaxRect ( startCharX , line1 . y , GUTTER_X + line1 . width , line1 . y + line1 . height ) ;
480+ Rect r = Rect . MinMaxRect ( startCharX , line1 . y , leftAlign ? ( GUTTER_X + line1 . width ) : _contentRect . xMax , line1 . y + line1 . height ) ;
480481 if ( clipped )
481482 resultRects . Add ( ToolSet . Intersection ( ref r , ref _contentRect ) ) ;
482483 else
483484 resultRects . Add ( r ) ;
484485 for ( int i = startLine + 1 ; i < endLine ; i ++ )
485486 {
486487 LineInfo line = _lines [ i ] ;
487- r = Rect . MinMaxRect ( GUTTER_X , r . yMax , GUTTER_X + line . width , line . y + line . height ) ;
488+ r = Rect . MinMaxRect ( GUTTER_X , r . yMax , leftAlign ? ( GUTTER_X + line . width ) : _contentRect . xMax , line . y + line . height ) ;
488489 if ( clipped )
489490 resultRects . Add ( ToolSet . Intersection ( ref r , ref _contentRect ) ) ;
490491 else
0 commit comments