Skip to content

Commit d8f9a21

Browse files
committed
Fix End of Doc Bugs
1 parent 8f02a6b commit d8f9a21

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Sources/CodeEditTextView/TextLayoutManager/TextLayoutManager+Public.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ extension TextLayoutManager {
166166
/// - Parameter offset: The offset to create the rect for.
167167
/// - Returns: The found rect for the given offset.
168168
public func rectForOffset(_ offset: Int) -> CGRect? {
169-
guard offset != lineStorage.length else {
169+
guard offset < lineStorage.length else {
170170
return rectForEndOffset()
171171
}
172172
guard let linePosition = determineVisiblePosition(for: lineStorage.getLine(atOffset: offset))?.position else {

Sources/CodeEditTextView/TextView/TextView+Mouse.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ extension TextView {
1212
// Set cursor
1313
guard isSelectable,
1414
event.type == .leftMouseDown,
15-
let offset = layoutManager.textOffsetAtPoint(self.convert(event.locationInWindow, from: nil)),
16-
let content = layoutManager.contentRun(at: offset) else {
15+
let offset = layoutManager.textOffsetAtPoint(self.convert(event.locationInWindow, from: nil)) else {
1716
super.mouseDown(with: event)
1817
return
1918
}
2019

21-
if case let .attachment(attachment) = content.data, event.clickCount < 3 {
20+
if let content = layoutManager.contentRun(at: offset),
21+
case let .attachment(attachment) = content.data, event.clickCount < 3 {
2222
handleAttachmentClick(event: event, offset: offset, attachment: attachment)
2323
return
2424
}

0 commit comments

Comments
 (0)