Cursor stuck on appending deleted text

I need to preserve data that is deleted by the user and add strike through styling to it. I am able to execute the first part i.e., appending the deleted data back but my cursor gets stuck whenever I make the first deletion. I am using appendTransaction to achieve the functionality. trxToApply is the transaction I am sending to be appended, oldstart is the position from where deletion starts const newFrom =,-1); trxToApply = trxToApply.setSelection(TextSelection.create(trxToApply.doc,newFrom));

I am using set selection to bring back the cursor to deleted text position but somehow it gets stuck there.