Fix scroll-to-visible bugs with column layout. Fixes #5486.

This commit is contained in:
Brent Simmons committed 2026-10-16 14:48:56 -07:00
1 parent ba42d71914
commit 2b604643db
2 files changed
+9 -9

No files matched your search

@@ -1082,7 +1082,7 @@ private extension TimelineViewController {
guard (0..<tableView.numberOfRows).contains(row), !tableView.isRowFullyVisible(row) else {
return false
}
tableView.scrollTo(row: row, extraHeight: 0)
tableView.scrollRowFullyIntoView(row)
return true
}
@@ -89,25 +89,25 @@ public extension NSTableView {
clipView.animator().bounds = clipView.constrainBoundsRect(rClipView)
}
/// Scrolls the minimum distance needed to show the whole row, unlike scrollTo(row:), which centers it.
/// A row above the visible area scrolls down just far enough to show it.
/// A row below the visible area is centered, so the rows after it show too.
func scrollRowFullyIntoView(_ row: Int) {
guard let scrollView = self.enclosingScrollView, let unobscuredDocumentRect else {
return
}
let r = rect(ofRow: row)
let deltaY: CGFloat
if r.minY < unobscuredDocumentRect.minY {
deltaY = r.minY - unobscuredDocumentRect.minY
} else if r.maxY > unobscuredDocumentRect.maxY {
deltaY = r.maxY - unobscuredDocumentRect.maxY
} else {
if r.maxY > unobscuredDocumentRect.maxY {
scrollTo(row: row, extraHeight: 0)
return
}
guard r.minY < unobscuredDocumentRect.minY else {
return
}
let clipView = scrollView.contentView
var bounds = clipView.bounds
bounds.origin.y += deltaY
bounds.origin.y += r.minY - unobscuredDocumentRect.minY
clipView.animator().bounds = clipView.constrainBoundsRect(bounds)
}