Skip to content

Commit

Permalink
closestIndex(to:) returns beginning of line if line fragment is unava…
Browse files Browse the repository at this point in the history
…ilable (#218)
  • Loading branch information
simonbs authored Oct 12, 2022
1 parent 2a30476 commit 7cd1833
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ extension LineController {

func closestIndex(to point: CGPoint) -> Int {
guard let closestLineFragment = lineFragment(closestTo: point) else {
return 0
return line.location
}
let localLocation = min(CTLineGetStringIndexForPosition(closestLineFragment.line, point), line.data.length)
return line.location + localLocation
Expand Down

0 comments on commit 7cd1833

Please sign in to comment.