Skip to content

Conversation

@paoloricciuti
Copy link
Member

closes #496

This issue is due to the fact that the array of the diagnostics get's out of sync with the actual code for a brief moment. This usually it's not a huge problem because it get's recomputed moments later but it can be a problem when the error falls outside of the max length of source code.

To avoid this issue i've added a bundling promise inside the context that get's reassigned whenever a bundling process starts and resolved immediately after the new bundle has been assigned to the store. The diagnostic has also been transformed from an array that get's recalculated dynamically to an async function that awaits the bundling process. Finally instead of simply passing the diagnostics to neocodemirror we create a linter extension passing the aforementioned async function. Codemirror will call and await this function at each modification.

A couple of points:

  1. This means the diagnostics feel a bit more slow because it has to wait for the bundling to finish, however this is more correct since the diagnostics immediately reflect the actual source code.
  2. This could also be "fixed" upstream in @PuruVJ @neocodemirror library, right now does work as intended but it uses setDiagnostics and it might be beneficial to use the linter extension instead to allow for async diagnostic calculation. So if @PuruVJ prefer to first upgrade @neocodemirror i can update this pr whenever he push a new release there.

@vercel
Copy link

vercel bot commented Jun 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hn ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2023 6:47pm
repl ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2023 6:47pm

@PuruVJ
Copy link
Collaborator

PuruVJ commented Jul 1, 2023

Strongly agree that this needs to be in neocodemirror. Will make a related PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REPL breaks when deleting attributes

2 participants