IndexOutOfBounds abgefangen

This commit is contained in:
Gerrit Linnemann 2020-08-16 10:28:42 +02:00
parent b4b1baa5ac
commit 6037240052

View File

@ -45,9 +45,14 @@ struct ContentView: View {
switch direction { switch direction {
case MoveCommandDirection.down: case MoveCommandDirection.down:
newIndex += 1 let max = self.fileList.count
if (newIndex + 1) < max {
newIndex += 1
}
case MoveCommandDirection.up: case MoveCommandDirection.up:
newIndex -= 1 if (newIndex - 1) >= 0 {
newIndex -= 1
}
default: default:
newIndex += 0 newIndex += 0
} }