EditorView.updateListener efficient way to check of editorView.state.doc.toString() changed ?

Inside a EditorView.updateListener (we are writing our own extension now).

Is there an efficient way to check if editorView.sate.doc.toString() has changed without doing an expensive string comparison over the entire buffer?

I.e. I have something that I want fired when the contents of the buffer changes.

However, I do not want it to fire due to cursor movement, selection, or adding of diagonistics.

I want it ONLY to fire when editorView.state.doc.toString() changes. However, I am wondering if there is a way to detect this change without doing an expensive string comparison.


See ViewUpdate.docChanged or if you want to compare to some specific document version, Text.eq is very efficient when the documents share structure (i.e. they are modified instances of the same original document).