Skip to content

Commit c504b10

Browse files
committed
Fix scroll bars not appearing on certain settings
Setting the bounds origins directly caused the scroll bar to not show up due to scroller management being hidden in `scroll(to: )`. This commit fixes that by canceling the animation after the call instead.
1 parent 6677700 commit c504b10

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

Sources/XiEditor/EditViewController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ class EditViewController: NSViewController, EditViewDataSource, FindDelegate, Sc
325325
if first..<last != visibleLines {
326326
document.sendWillScroll(first: first, last: last)
327327
visibleLines = first..<last
328+
329+
// Cancels the scroll animation to prevent jerky scrolling.
330+
scrollView.contentView.setBoundsOrigin(newOrigin)
328331
}
329332
editView.needsDisplay = true
330333
}

Sources/XiEditor/XiClipView.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@ protocol ScrollInterested: class {
2121
class XiClipView: NSClipView {
2222
weak var delegate: ScrollInterested?
2323

24-
// Smooth scrolling (like the MacBook trackpad or Apple Magic Mouse) sends scroll events that are chunked, continuous and cumulative,
25-
// and thus the scroll view's clipView's bounds is set properly (in small increments) for each of these small chunks of scrolling.
26-
// Scrolling with notched mice scrolls in discrete units, takes into account acceleration but does not redraw the view when the view is continuously redrawn (like in xi-mac) during scrolling.
27-
// This is because the bounds origin is only set after the scrolling has stopped completely.
28-
// We bypass this by simply setting the bound origin immediately.
2924
override func scroll(to newOrigin: NSPoint) {
3025
delegate?.willScroll(to: newOrigin)
31-
super.setBoundsOrigin(newOrigin)
26+
super.scroll(to: newOrigin)
3227
}
3328
}

0 commit comments

Comments
 (0)