Fixed cursor position and undo/redo merges
Fixes two things:
- Cursor positions are being incorrectly calculated in scenarios where keystroke actions reject some input text.
- Undo/redo operations were buggy and the commands would not merge often leading to single character undo/redo most of the times.
Edited by Pratham Gandhi