Skip to content

Commit

Permalink
Merge pull request xi-editor#477 from nangtrongvuon/bug_fixes/476-scr…
Browse files Browse the repository at this point in the history
…oll-bar-disappearing

Fix scrollers not appearing for certain settings
  • Loading branch information
nangtrongvuon authored Sep 25, 2019
2 parents 6677700 + c504b10 commit c9c27ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Sources/XiEditor/EditViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ class EditViewController: NSViewController, EditViewDataSource, FindDelegate, Sc
if first..<last != visibleLines {
document.sendWillScroll(first: first, last: last)
visibleLines = first..<last

// Cancels the scroll animation to prevent jerky scrolling.
scrollView.contentView.setBoundsOrigin(newOrigin)
}
editView.needsDisplay = true
}
Expand Down
7 changes: 1 addition & 6 deletions Sources/XiEditor/XiClipView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ protocol ScrollInterested: class {
class XiClipView: NSClipView {
weak var delegate: ScrollInterested?

// Smooth scrolling (like the MacBook trackpad or Apple Magic Mouse) sends scroll events that are chunked, continuous and cumulative,
// and thus the scroll view's clipView's bounds is set properly (in small increments) for each of these small chunks of scrolling.
// 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.
// This is because the bounds origin is only set after the scrolling has stopped completely.
// We bypass this by simply setting the bound origin immediately.
override func scroll(to newOrigin: NSPoint) {
delegate?.willScroll(to: newOrigin)
super.setBoundsOrigin(newOrigin)
super.scroll(to: newOrigin)
}
}

0 comments on commit c9c27ea

Please sign in to comment.