Chapter 15 - moveKeywords trips Fatal error:Index out of range

Calling the ‘moveKeyword’ method in SettingsView causes Xcode to crash while trying to move a List entry by accident when its’ the one and only entry.

See Code sample on page 513 where ‘destination’ will be -1.

source > destination ? destination : destination - 1)”

Excerpt From: By Marin Todorov. “Combine”. Apple Books.

A minor change in the first code line of the method helped me:

guard let source = source.first,destination != settings.keywords.endIndex, destination > 0 else { return }

@afrank Thank you for sharing your solution - much appreciated!