Wait you wrote synchronously! Sorry again.
So I tried this:
import { ensureSyntaxTree } from '@codemirror/language'
set value (v) {
const state = this.view.state
this.view.dispatch({
changes: { from: 0, to: state.doc.length, insert: v || '' }
})
ensureSyntaxTree(this.view.state, state.doc.length, 5000)
foldAll(this.view)
}
but no luck.
I am not sure listening to updates will work for me, since I need to trigger the folding only when I set the editor to a new value (for example when you navigate onto that particular page in an SPA).
(I tried to figure out how to go this route, and I realise that UpdateListener is the key, but I haven’t managed to figure out how to actually use it).