Fix linenumbers when undoing multiple changes

To reproduce, for example create two selections on different lines, press enter twice and undo once.