|
From: | Wilhelm Kirschbaum |
Subject: | bug#58711: Treesit hangs when calling treesit-search-forward |
Date: | Mon, 14 Nov 2022 12:03:11 +0200 |
> On Nov 13, 2022, at 10:32 PM, Wilhelm Kirschbaum <wilhelm@floatpays.co.za> wrote:
>
> This works for me for all cases I managed to test:
>
> ( I have to keep track of the EOL and BOL to ensure that we don't jump to parents or children. )
>
> (defun heex--treesit-largest-node-at-point (&optional node)
> "Find the largest node at point or from specified NODE."
> (save-excursion
> (forward-comment (point-max))
> (let ((node-list
> (cl-loop for node = (or node (treesit-node-at (point)))
> then (treesit-node-parent node)
> while (and node (not (equal (treesit-node-type node) "fragment")))
> if (eq (treesit-node-start node)
> (point))
> collect node)))
> (car (last node-list)))))
For largest node at point, you can probably use something like
(treesit-parent-while (or node (treesit-node-at (point)))
(lambda (n) (eq (treesit-node-start n) (point))))
Yuan
[Prev in Thread] | Current Thread | [Next in Thread] |