Make line number view opaque if text is unwrapped

This commit is contained in:
1024jp 2018-11-16 11:12:32 +09:00
parent d39693afe1
commit bcb4a8e19a
2 changed files with 13 additions and 2 deletions

View File

@ -13,6 +13,7 @@ Change Log
### Improvements
- Avoid drawing variant sequence as invisible control characters.
- Make line number view opaque if lines are unwrapped on macOS 10.14 to avoid drawing the editor's text over the line numbers.
- [tirivial] Draw vertical tabs as general invisible control characters.

View File

@ -149,11 +149,21 @@ final class LineNumberView: NSRulerView {
/// make background transparent
override var isOpaque: Bool {
return self.textView?.isOpaque ?? true
guard let textView = self.textView else { return true }
if textView.isOpaque { return true }
// avoid overlapping line numbers with the text in the text view
// -> On macOS 10.14 (and later?), text view is drawn under the ruler view. (2018-11 macOS 10.14)
if NSAppKitVersion.current > .macOS10_13_4 {
return !textView.wrapsLines
}
return false
}
/// just before view will be attached
/// just before the receiver attaches to a superview
override func viewWillMove(toSuperview newSuperview: NSView?) {
super.viewWillMove(toSuperview: newSuperview)