Use real distance when deciding whether to save a new version

When deciding whether to store a version, we need to compare the current
text with the latest stored text. (When storing distance, we do the
comparison after we have saved a version, so if a version is not saved
it is ignored.)