Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
lukhnos committed Dec 1, 2023
1 parent d580610 commit 17ac91e
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public class VerticalCandidateController: CandidateController {
}

public override func reloadData() {
maxCandidateAttrStringWidth = ceil(candidateFont.pointSize * 1.0 + candidateTextPadding)
maxCandidateAttrStringWidth = ceil(candidateFont.pointSize + candidateTextPadding)
tableView.reloadData()
layoutCandidateView()
if delegate?.candidateCountForController(self) ?? 0 > 0 {
Expand Down Expand Up @@ -261,21 +261,16 @@ public class VerticalCandidateController: CandidateController {
let visibleRowIndexes = tableView.rows(in: visibleRect)
let selected = selectedCandidateIndex

scrollTimer?.invalidate()
if selected == UInt.max || visibleRowIndexes.contains(Int(selected)) == false {
keyLabelStripView.highlightedIndex = -1
keyLabelStripView.setNeedsDisplay(keyLabelStripView.frame)
scrollTimer = Timer.scheduledTimer(withTimeInterval: 0.25, repeats: false) { timer in
self.tableView.scrollRowToVisible(visibleRowIndexes.lowerBound)
self.scrollTimer?.invalidate()
self.scrollTimer = nil
}
} else {
scrollTimer = Timer.scheduledTimer(withTimeInterval: 0.25, repeats: false) { timer in
self.tableView.scrollRowToVisible(visibleRowIndexes.lowerBound)
self.scrollTimer?.invalidate()
self.scrollTimer = nil
}
}

scrollTimer?.invalidate()
scrollTimer = Timer.scheduledTimer(withTimeInterval: 0.25, repeats: false) { timer in
self.tableView.scrollRowToVisible(visibleRowIndexes.lowerBound)
self.scrollTimer?.invalidate()
self.scrollTimer = nil
}
}
}
Expand Down

0 comments on commit 17ac91e

Please sign in to comment.