Skip to content

Commit a0e5dfe

Browse files
committed
(#365) Fixed caret positioning for non-latin char input
1 parent 38d0678 commit a0e5dfe

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Proton/Sources/Swift/Core/RichTextView.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,9 @@ class RichTextView: AutogrowingTextView {
837837
let lineRect = layoutManager.boundingRect(forGlyphRange: NSRange(location: location, length: 0), in: textContainer)
838838

839839
var caretRect = super.caretRect(for: position)
840-
caretRect.origin.y = lineRect.minY + textContainerInset.top
840+
// For non-Latin chars, the line height is calculated differently. Hence, using the higher of
841+
// existing Caret rect or lineHeight.y position for caret positioning.
842+
caretRect.origin.y = max(caretRect.origin.y, lineRect.minY + textContainerInset.top)
841843
caretRect.size.height = lineRect.height
842844
return caretRect
843845
}

0 commit comments

Comments
 (0)