Perf question: refresh() vs. marker.changed()


I’ve got a project that parses the editor contents and generates an AST. The root nodes for that AST are then rendered as a DOM tree, and the original text ranges of those roots are replaced with widgets. The end result is: no text, just DOM widgets.

When there’s a change to the code, it’s re-parsed and re-rendered, such that only the changed root nodes get redrawn. Typically that means just one or two roots are changed at any time.

What’s the cheapest way to recalculate line heights, for the sake of cursor position? cm.refresh(), or widget.changed() for the modified roots?


widget.changed() (preferably wrapping all the calls in a cm.operation) should be cheaper.

1 Like

Thanks, Marijn!