Redo optimization for big files; track typing and count but do not count again if only the cursor is moving; count if selection is not empty and changes