I am developing my DSL code complement based on codemirror6.
When I typed a colon after the word layout
, I get a list of options for ‘horizontal’, ‘vertical’, which is correct
a=true.show(layout:)
object [1:0..1:20]
└─ DefineStatement [1:0..1:20]
├─ VariableDefine [1:0..1:1]: "a"
├─ ASSIGN [1:1..1:2]: "="
├─ Boolean [1:2..1:6]: "true"
├─ . [1:6..1:7]: "."
└─ f_show [1:7..1:20]
├─ show [1:7..1:11]: "show"
├─ ( [1:11..1:12]: "("
├─ layout [1:12..1:18]: "layout"
├─ : [1:18..1:19]: ":"
├─ ? 1:19
└─ ) [1:19..1:20]: ")"
But if I enter a space
after :
, it doesn’t work right.
I used resolveInner
to get the node at the current cursor position
let inner = tree.resolveInner(context.pos, -1)
In the absence of a space
, the inner node is “:”, but if there is a space, it changes to “f_show”
I want to be able to get the node “:” or the error node even if I typed a space
I tried enterUnfinishedNodesBefore
, but the output also did not meet expectations
let tree : Tree = syntaxTree(context.state)
// log => object
console.log(tree.topNode.enterUnfinishedNodesBefore(context.pos).name)
let inner = tree.resolveInner(context.pos, -1)
// log => f_show
console.log(inner.enterUnfinishedNodesBefore(context.pos).name)
It should be that I’m not using it in the right way, how can I fix it?