mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-28 01:00:52 -07:00
Improve treesit-search-forward-goto so it doens't stuck at EOF
* lisp/treesit.el (treesit-search-forward-goto): Handle the edge case.
This commit is contained in:
parent
2f6b017e3d
commit
b341864d90
1 changed files with 6 additions and 0 deletions
|
|
@ -826,6 +826,12 @@ or end of the matches node, it can be either \\='start or
|
|||
ALL, BACKWARD, and UP are the same as in `treesit-search-forward'."
|
||||
(let ((node (treesit-node-at (point)))
|
||||
(start (point)))
|
||||
;; Often the EOF (point-max) is a newline, and `treesit-node-at'
|
||||
;; will return nil at that point (which is fair). But we need a
|
||||
;; node as the starting point to traverse the tree. So we try to
|
||||
;; use the node before point.
|
||||
(when (and (not node) (eq (point) (point-max)))
|
||||
(setq node (treesit-node-at (max (1- (point)) (point-min)))))
|
||||
;; When searching forward, it is possible for (point) < start,
|
||||
;; because `treesit-search-forward' goes to parents.
|
||||
(while (and node (if backward
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue