Skip to content

Commit 2fdbed0

Browse files
committed
Layout on WillAppear
1 parent 00bcea1 commit 2fdbed0

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Sources/CodeEditSourceEditor/Controller/TextViewController+LoadView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ extension TextViewController {
2929
)
3030

3131
minimapView = MinimapView(textView: textView, theme: theme)
32+
minimapView.postsFrameChangedNotifications = true
3233
minimapView.isHidden = !showMinimap
3334
scrollView.addFloatingSubview(minimapView, for: .vertical)
3435

@@ -68,7 +69,7 @@ extension TextViewController {
6869
func setUpConstraints() {
6970
guard let findViewController else { return }
7071

71-
let maxWidthConstraint = minimapView.widthAnchor.constraint(lessThanOrEqualToConstant: 150)
72+
let maxWidthConstraint = minimapView.widthAnchor.constraint(lessThanOrEqualToConstant: 140)
7273
let relativeWidthConstraint = minimapView.widthAnchor.constraint(
7374
equalTo: view.widthAnchor,
7475
multiplier: 0.17

Sources/CodeEditSourceEditor/Controller/TextViewController+ReloadUI.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import AppKit
99

10-
extension TextViewController [
10+
extension TextViewController {
1111
func reloadUI() {
1212
textView.isEditable = isEditable
1313
textView.isSelectable = isSelectable
@@ -20,4 +20,4 @@ extension TextViewController [
2020
minimapView.updateContentViewHeight()
2121
minimapView.updateDocumentVisibleViewPosition()
2222
}
23-
]
23+
}

Sources/CodeEditSourceEditor/Controller/TextViewController.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,13 @@ public class TextViewController: NSViewController {
328328
/// A default `NSParagraphStyle` with a set `lineHeight`
329329
package lazy var paragraphStyle: NSMutableParagraphStyle = generateParagraphStyle()
330330

331+
override public func viewWillAppear() {
332+
super.viewWillAppear()
333+
// The calculation this causes cannot be done until the view knows it's final position
334+
updateTextInsets()
335+
minimapView.layout()
336+
}
337+
331338
deinit {
332339
if let highlighter {
333340
textView.removeStorageDelegate(highlighter)

0 commit comments

Comments
 (0)