Skip to content

Get node/path by position #361

Closed Answered by squeedee
squeedee asked this question in Q&A
Feb 20, 2022 · 2 comments · 4 replies
Discussion options

You must be logged in to vote

For others who might ask: no there isn't currently a fast index to find a node at a position (caret). Which should have been how I posed the question :D

In my mind, a b-tree with spanning indexes (just using first-position) indexing position to a node, would work here. It would need to support live edits to the Document AST for completeness (not just create-on-parse). Finally it would probably slow down parsing, and definitely slow down insert/edits, because creating or mutating a node would necessarily require the right side of the tree to be rebuilt, so it would definitely need to be guarded by an option eg: parseDocument(doc,{createPositionIndex: true}

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@squeedee
Comment options

@squeedee
Comment options

@eemeli
Comment options

@squeedee
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by squeedee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants