Fix line number display with markedText (fix #882)

This commit is contained in:
1024jp 2018-12-09 14:32:05 +09:00
parent ce19977137
commit bcda6405a7
2 changed files with 11 additions and 1 deletions

View File

@ -2,6 +2,15 @@
Change Log
==========================
3.6.9 (unreleased)
--------------------------
### Fixes
- Fix an issue where some of line numbers disappeared on macOS 10.13 (and earlier?) when Japanese text is being input.
3.6.8 (303)
--------------------------

View File

@ -52,8 +52,9 @@ extension NSTextView {
let selectedLineRanges = self.selectedRanges.map { (self.string as NSString).lineRange(for: $0.rangeValue) }
// get glyph range of which line number should be drawn
// -> Requires additionalLayout to obtain glyphRange for markedText. (2018-12 macOS 10.14 SDK)
let layoutRect = rect.offset(by: -self.textContainerOrigin)
let glyphRangeToDraw = layoutManager.glyphRange(forBoundingRectWithoutAdditionalLayout: layoutRect, in: textContainer)
let glyphRangeToDraw = layoutManager.glyphRange(forBoundingRect: layoutRect, in: textContainer)
// count up lines until the interested area
let firstIndex = layoutManager.characterIndexForGlyph(at: glyphRangeToDraw.location)