The computation of the completion end position was taking place too early, before we checked if the buffer did get modified. Fixes #3349