How does replaceSelection work?

While calling replaceSelection I am getting the follow error

.

I am calling replaceSelection on a button operation and passing a string to it. Please can you help me in this regard?

Can you create a runnable bit of example code that demonstrates the error? It sounds like you may be applying the resulting change to the wrong state, but it’s hard to know from just the message.

Hi you can find an example over here: codemirror6-replaceSelectionTrial - CodeSandbox. The code is implemented in file: src/app/css-code-editor/css-code-editor.component.ts.

EditorState is not a mutable object, so this.editorState will still be pointing at the start state after the view moves on to a new state.

Thank you very much! That worked!