Skip to content

Commit 7b2deea

Browse files
committed
Fix Ambiguous Gutter Position
1 parent 8985e21 commit 7b2deea

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Sources/CodeEditSourceEditor/Controller/TextViewController+LoadView.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ extension TextViewController {
2323
delegate: self
2424
)
2525
gutterView.updateWidthIfNeeded()
26-
scrollView.addFloatingSubview(
27-
gutterView,
28-
for: .horizontal
29-
)
26+
scrollView.addFloatingSubview(gutterView, for: .horizontal)
3027

3128
minimapView = MinimapView(textView: textView, theme: theme)
3229
scrollView.addFloatingSubview(minimapView, for: .vertical)
@@ -90,6 +87,8 @@ extension TextViewController {
9087
minimapXConstraint,
9188
maxWidthConstraint,
9289
relativeWidthConstraint,
90+
91+
gutterView.topAnchor.constraint(equalTo: textView.topAnchor)
9392
])
9493
}
9594

@@ -123,7 +122,11 @@ extension TextViewController {
123122
object: textView,
124123
queue: .main
125124
) { [weak self] _ in
126-
self?.gutterView.frame.size.height = (self?.textView.frame.height ?? 0) + 10
125+
guard let scrollView = self?.scrollView else { return }
126+
self?.gutterView.frame.size.height = max(
127+
(self?.textView.frame.height ?? 0) + 10,
128+
(self?.scrollView.documentVisibleRect.height ?? 0.0) + (self?.scrollView.contentInsets.vertical ?? 0.0)
129+
)
127130
self?.gutterView.needsDisplay = true
128131
}
129132

0 commit comments

Comments
 (0)