Disallow the root node from becoming point-node

Unless it's the only node, anyway. This fixes the issue of not being
able to navigate across the children of the document root without
first doing a down-node.
This commit is contained in:
Skylar Hill 2023-11-04 23:16:18 -05:00
parent 4af941954d
commit d7ac8fc31c
1 changed files with 8 additions and 4 deletions

View File

@ -91,9 +91,12 @@
(define tree (ts-parser-parse-string scheme-parser
#f
contents))
(set-fields state
((sloth-state-tree) tree)
((sloth-state-point-node) (ts-tree-root-node tree))))
(set-fields
state
((sloth-state-tree) tree)
((sloth-state-point-node) (or (ts-node-child (ts-tree-root-node tree)
0)
(ts-tree-root-node tree)))))
;; These are stubs for now, but they'll get more complex
;; as we add features and more processing is needed on updates
@ -162,7 +165,8 @@
(define (up-node state)
(define target (ts-node-parent (sloth-state-point-node state)))
(if target
(if (and target
(not (equal? target (ts-tree-root-node (sloth-state-tree state)))))
(let ((point (ts-node-start-point target)))
(move (sloth-state-win state)
(car point) (cdr point))