I have the following basic editor:
import { EditorView, keymap, drawSelection } from '@codemirror/view'
import { indentUnit } from '@codemirror/language'
import { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands'
import { java } from '@codemirror/lang-java'
export const basicSetup = [
indentUnit.of(' '),
history(),
drawSelection(),
keymap.of([
...defaultKeymap,
...historyKeymap,
indentWithTab
])
]
const editor = new EditorView({
extensions: [basicSetup, java()],
parent: document.getElementById('editor'),
doc: 'class HelloWorld {\n public static void main(String[] args) {\n System.out.println("Hello, World!");\n }\n}'
})
When I press enter in an indented block, such as the one with System.out.println()
, an uncaught exception stating ast.resolveStack is not a function
is logged with the following stack trace:
TypeError: ast.resolveStack is not a function
at syntaxIndentation (@codemirror+language@6.10.1/node_modules/@codemirror/language/dist/index.js)
at getIndentation (@codemirror+language@6.10.1/node_modules/@codemirror/language/dist/index.js)
...
The same issue can be seen in @codemirror/lang-cpp
, but not in other language modes like @codemirror/lang-javascript
, or if I remove the language modes entirely from my code.
Further, the code snippet above used to work with older versions of codemirror.
Am I doing something wrong in the above snippet and how can I fix it?
Thanks!