Fixes an underlying issue in the tableViewSelectionDidChange method.

This commit is contained in:
zonble 2022-01-19 13:20:27 +08:00
parent 7e2d3df5ba
commit 95f88ce802
1 changed files with 5 additions and 3 deletions

View File

@ -310,10 +310,12 @@ extension VerticalCandidateController: NSTableViewDataSource, NSTableViewDelegat
// keep track of the highlighted index in the key label strip
let firstVisibleRow = tableView.row(at: scrollView.documentVisibleRect.origin)
// firstVisibleRow cannot be larger than selectedRow.
if firstVisibleRow > selectedRow {
return
if selectedRow >= firstVisibleRow {
keyLabelStripView.highlightedIndex = UInt(selectedRow - firstVisibleRow)
} else {
keyLabelStripView.highlightedIndex = UInt.max
}
keyLabelStripView.highlightedIndex = UInt(selectedRow - firstVisibleRow)
keyLabelStripView.setNeedsDisplay(keyLabelStripView.frame)
// fix a subtle OS X "bug" that, since we force the scroller to appear,