uiwjs / uiwjs/react-codemirror

CM6 "Idle" state not triggering

Open
#361 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
161
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the CodeSandbox example and compare the direct CodeMirror 6 extension with the same extension in react-codemirror's extension array. Verify whether changing content reaches the documented idle state and whether the linter callback runs; done means linting triggers after content changes without the reported forceLinting workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.