Skip to content

Commit

Permalink
fix: crash in rare unknown scenario scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Oct 6, 2020
1 parent c3f0686 commit 08581f5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/ui/main-window/ThumbnailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ class ThumbnailsView: NSVisualEffectView {

func nextRow(_ direction: Direction) -> [ThumbnailView]? {
let step = direction == .down ? 1 : -1
let currentRow = Windows.focusedWindow()!.row!
let nextRow = (currentRow + step) % rows.count
let nextRow_ = nextRow < 0 ? rows.count + nextRow : nextRow
if ((step > 0 && nextRow_ < currentRow) || (step < 0 && nextRow_ > currentRow)) &&
(KeyRepeatTimer.isARepeat || KeyRepeatTimer.timer?.isValid ?? false) {
KeyRepeatTimer.timer?.invalidate()
return nil
if let currentRow = Windows.focusedWindow()?.row {
let nextRow = (currentRow + step) % rows.count
let nextRow_ = nextRow < 0 ? rows.count + nextRow : nextRow
if ((step > 0 && nextRow_ < currentRow) || (step < 0 && nextRow_ > currentRow)) &&
(KeyRepeatTimer.isARepeat || KeyRepeatTimer.timer?.isValid ?? false) {
KeyRepeatTimer.timer?.invalidate()
return nil
}
return rows[nextRow_]
}
return rows[nextRow_]
return nil
}

func navigateUpOrDown(_ direction: Direction) {
Expand Down

0 comments on commit 08581f5

Please sign in to comment.