Fix drawing last line number

This commit is contained in:
1024jp 2018-12-15 01:24:07 +09:00
parent 155fe10ab5
commit 51606ed728
2 changed files with 16 additions and 7 deletions

View File

@ -13,6 +13,11 @@ Change Log
- Change the label of the option “Count each line ending as one character” in General pane to “Ignore line endings when counting characters” (the value reversed).
### Fixes
- [trivial] Fix a potential issue where last empty line number could be drawn at the first line position under specific condition.
3.6.9 (305)
--------------------------

View File

@ -84,13 +84,17 @@ extension NSTextView {
guard includingExtraLine else { return }
let extraLineRect = layoutManager.extraLineFragmentUsedRect
if !extraLineRect.isEmpty, (layoutRect.minY...layoutRect.maxY).overlaps(extraLineRect.minY...extraLineRect.maxY) {
let lineNumber = max(self.string.numberOfLines(includingLastLineEnding: true), 1)
let isSelected = (selectedLineRanges.last?.location == (self.string as NSString).length)
body(.new(lineNumber, isSelected), extraLineRect)
}
let extraLineRect = layoutManager.extraLineFragmentRect
guard
!extraLineRect.isEmpty,
(layoutRect.minY...layoutRect.maxY).overlaps(extraLineRect.minY...extraLineRect.maxY)
else { return }
lineNumber = max(self.string.numberOfLines(includingLastLineEnding: true), 1)
let isSelected = (selectedLineRanges.last?.location == (self.string as NSString).length)
body(.new(lineNumber, isSelected), extraLineRect)
}
}