-
The bug was that the undo operation (Ctrl+z) moved the cursor to the last line of the buffer. When moving line(s) down or up (with Alt+Down or Alt+Up), there is the special case of the buffer end that doesn't end with a newline character. The previous solution basically canonicalized the buffer by always having a trailing newline. Then removing the trailing newline if it was inserted. So now, to fix the bug, a trailing newline is inserted *only* when the end of the buffer is involved. Basic regression/unit tests are included, so this bug should hopefully not re-appear.