Is getting line numbers possible?

Hello,

We’re working on building a CLI to catch syntactic errors when run on files. We look for error nodes in the tree, catch the adjacent node and return it as an erroneous part.

Is there a way to get exact line numbers in this?

We are returning cursor position right now, but were trying get more insight in terms of position of the erroneous part.

Not in the tree itself, but if you have the document, it’s not hard to create a representation that allows efficient mapping between positions and lines (you could even use @codemirror/text for that).

1 Like