Fix OOB error for combination of selection -> resize -> undo