react-codemirror icon indicating copy to clipboard operation
react-codemirror copied to clipboard

CM6 "Idle" state not triggering

Open VickyKoblinski opened this issue 2 years ago • 1 comments

Hey I'm new to CM but I was having a lot of trouble getting the linter to work with this extension. Part of the problem was not great examples on anyone's part plus realizing there's a huge difference between CM5 and CM6 and being careful what I read, and using an abstraction on top of CM6. Anyways, I sort of narrowed down the problem I'm having.

Take this example: https://codesandbox.io/s/codesandbox-next-363-forked-nmo1pu?file=/src/index.js:287-297

This works as expected. You can put a console.log in the extension's callback and see it trigger. Now take that same extension, and put it into react-codemirror's extension array, adding the console.log for debugging. Change content, and notice how the linter never gets called.

I did find a workaround to call forceLinting in the onChange and onCreateEditor callback functions for now.

Per the docs here https://codemirror.net/docs/ref/#lint.linter it says Given a diagnostic source, this function returns an extension that enables linting with that source. It will be called whenever the editor is idle (after its content changed).

It seems that react-codemirror isn't getting to this idle state?

VickyKoblinski avatar Jul 23 '22 18:07 VickyKoblinski

This may also be caused by the internal integration of multiple extensions. @VickyKoblinski

jaywcjlove avatar Jul 24 '22 11:07 jaywcjlove