Fix join lines so that only a single space will exist between two lines

Hmmm you are right, it does bypass the undo manager. I'll have to take another look at a different solution then.