File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Sources/CodeEditTextView/TextSelectionManager Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,10 @@ extension TextSelectionManager {
1919 /// - textSelection: The selection to use.
2020 /// - Returns: An array of rects that the selection overlaps.
2121 func getFillRects( in rect: NSRect , for textSelection: TextSelection ) -> [ CGRect ] {
22- guard let layoutManager else { return [ ] }
23- let range = textSelection. range
22+ guard let layoutManager,
23+ let range = textSelection. range. intersection ( textView? . visibleTextRange ?? . zero) else {
24+ return [ ]
25+ }
2426
2527 var fillRects : [ CGRect ] = [ ]
2628
@@ -33,7 +35,7 @@ extension TextSelectionManager {
3335 }
3436
3537 // Pixel align these to avoid aliasing on the edges of each rect that should be a solid box.
36- return fillRects. map { $0. intersection ( insetRect ) . pixelAligned }
38+ return fillRects. map { $0. pixelAligned }
3739 }
3840
3941 /// Find fill rects for a specific line position.
You can’t perform that action at this time.
0 commit comments