Selection invertion works

Reworked invertSelection logic.
addRangeToRanges() simplifies range input.
Fixed an unnoticed bug (used 'i' in place of 't' in showDiffs())