strange behavior of setState

As demonstrated, when I open a new file through setState(newState), the cursor keeps returning to the starting position and cannot be edited normally, any suggestion?
Screen Recording 2022-05-18 at 11.28.19

I can’t reproduce this. Try reducing it to the minimal script that demonstrates the issue.

Thanks for reply, after a day of exploration, I found the problem, I setState in every doc change this cause the problem