Best way to manage 'doc-has-changed' status

Using code mirror for a text editor.
When loading the editor content from a file I want to display

  • if the editor text has been changed
  • or is still/again the same as the file content

Broadly having 2 approaches in mind:

  1. Create a checksum of the files content when loading and on update.docChanged calculate a new one and see if they differ
  2. Use the change descriptions / history structure

(1) should be doable, just worry about the performance/extra load.
For (2) haven’t found an exact way yet. Looked at the serializable history field which I extract anyway, but don’t see an obvious way to reuse (also since a save shouldn’t wipe out history).

Any thoughts or advise ?

Store state.doc for the version you are interested in, and do baseDoc.eq(state.doc) at any time to see if the given state has the same document.