How to insert a snippet at the current cursor position

Hi,

I want to insert a custom snippet at the current cursor position.
But the following code does not work:

editorView.dispatch({changes: {from: 0, insert: "test${1}"}})

This problem has been bothering me for a long time, is there a way to solve it?

That should insert the string at position 0, and that’s exactly what it does for me. You might want to be a bit more specific than “does not work”.