iterator_to requires that the object be in the list, which is sometimes
not the case when processing a commit which removed the active line or a
selected line. To handle this, add a checked version that returns
Events.end() when it is not in the list rather than crashing.
The "previous" line for the first line was actually the last line of the
file, and the previous line for the second line was ignored entirely.
Closes#1719.