Exporting DocInput from the language package

Hey, could DocInput from @codemirror/language be exported? It’s pretty much essential for when you need to do incremental parsing outside of the editor view.

Are you keeping these documents that aren’t in an editor as CodeMirror Text instances? What for?

We’re doing code completion suggestions with syntax highlighting. Looks something like this:

The suggested change here is represented as a ChangeSet, which can be applied to the editor’s current document. To do syntax highlighting, we apply the change to the document and run that through the relevant parser, taking care to actually use the incremental parsing features of CodeMirror. That way you get correct highlighting fairly cheaply.

All of that works with Text naturally, but the one place where you’re forced to convert the entire document to a string (or at least a large part of it) is that parse step. It’d be nice to be able to do this all “correctly” and use DocInput.

That makes sense. This patch exports it.

1 Like

Thank you!