Skip to content

Commit

Permalink
Fixed crash in selector popup ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Sep 8, 2024
1 parent 9244b0c commit d8bdb2f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ui/widget_builder_selector_popup.nim
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ method createUI*(self: SelectorPopup, builder: UINodeBuilder, app: App): seq[pro
builder.panel(&{FillX, LayoutVertical} + yFlag):
let maxLineCount = floor(bounds.h / totalLineHeight).int
let targetNumRenderedItems = min(maxLineCount, items.filteredLen)
var lastRenderedIndex = min(self.scrollOffset + targetNumRenderedItems - 1, items.high)
var lastRenderedIndex = min(self.scrollOffset + targetNumRenderedItems - 1, items.filteredLen - 1)

if self.selected < self.scrollOffset:
self.scrollOffset = self.selected
lastRenderedIndex = min(self.scrollOffset + targetNumRenderedItems - 1, items.high)
lastRenderedIndex = min(self.scrollOffset + targetNumRenderedItems - 1, items.filteredLen - 1)

if self.selected > lastRenderedIndex:
self.scrollOffset = max(self.selected - targetNumRenderedItems + 1, 0)
lastRenderedIndex = min(self.scrollOffset + targetNumRenderedItems - 1, items.high)
lastRenderedIndex = min(self.scrollOffset + targetNumRenderedItems - 1, items.filteredLen - 1)

assert self.scrollOffset >= 0
assert self.scrollOffset < items.filteredLen
Expand Down

0 comments on commit d8bdb2f

Please sign in to comment.