Skip to content

Commit 40458fe

Browse files
Fix Hidden Cursor At End Of Doc (#39)
1 parent 9e6d94a commit 40458fe

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Sources/CodeEditTextView/TextSelectionManager/TextSelectionManager.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,15 @@ public class TextSelectionManager: NSObject {
233233
/// - Parameter range: The range the cursor is at.
234234
/// - Returns: The height the cursor should be to match the text at that location.
235235
fileprivate func heightForCursorAt(_ range: NSRange) -> CGFloat? {
236-
let selectedLine = layoutManager?.textLineForOffset(range.location)
237-
return selectedLine?
236+
guard let selectedLine = layoutManager?.textLineForOffset(range.location) else {
237+
return layoutManager?.estimateLineHeight()
238+
}
239+
return selectedLine
238240
.data
239241
.lineFragments
240-
.getLine(atOffset: range.location - (selectedLine?.range.location ?? 0))?
242+
.getLine(atOffset: range.location - (selectedLine.range.location))?
241243
.height
244+
?? layoutManager?.estimateLineHeight()
242245

243246
}
244247

0 commit comments

Comments
 (0)