diagnosticCount: is not in sync


I am using vue-codemirror6 with custom linter that I wrote, after the linter returns an error I would like to do something in vue-land. for that I am trying to listen to event to see if I have diagnostics.

The problem is that diagnosticCount is returning zero even If I have diagnostic shown.

I created a reproducer of the show (based on CodeMirror Lint Example source) - cm.html · GitHub
When you open the page:

  1. You see there is diagnostic error shown and in console DiagnosticCount 0
  2. Once I loose focus from the editor I am getting DiagnosticCount 1 in console.
  3. If I change the regex to be string, the diagnostic disappear (which is expected), but DiagnosticCount is still 1.

I tried instead of using EditorState.transactionExtender to poll (with window.setInterval) the diagnosticCount but it’s zero.

Am I doing something wrong here? or this is a bug?

Another way to ask this question might be: is there event that codemirror exposes when we have diagnostics - so I can block form submit? (form have codemirror input).

There is no way diagnosticCount is out of sync with the lint marker display—it uses the same data source. You may be querying the wrong state, or at the wrong time.

Hi marjin, thanks for your reply.

As I said i might be doing something wrong, hence I wrote here a question.

Ignoring my code above and “sync” issue - what’s the best/recommended way to block form submit (form have codemirror input) - is there event I can listen to with updated state?