how to set view stay in current position when cm.doc.setValue()

when I use doc.setValue(), the editor scroll to first line,but I dont want to have this effect
how to set view stay in current position when cm.doc.setValue()??
thank you!

Perhaps you could get the current position first, then call setValue() then attempt to move to the original position.

how to get current position?
That’s what bothers me.

You can use getScollInfo and scrollTo to do this.

But generally, if you’re just making small changes to the document, setValue is the wrong approach, and you should try to break your update down into replaceRange calls.