Handle narrowed buffers in treesit-forward-sentence (bug#76679)
* lisp/treesit.el (treesit-forward-sentence): When no more sentences are found, move to the end of the buffer or to the range boundary at the 'treesit-parser' overlay's end.
This commit is contained in:
parent
d1ce9fbf49
commit
59a67dcde4
1 changed files with 10 additions and 3 deletions
|
@ -3418,9 +3418,16 @@ What constitutes as text and source code sentence is determined
|
|||
by `text' and `sentence' in `treesit-thing-settings'."
|
||||
(if (treesit-node-match-p (treesit-node-at (point)) 'text t)
|
||||
(funcall #'forward-sentence-default-function arg)
|
||||
(funcall
|
||||
(if (> arg 0) #'treesit-end-of-thing #'treesit-beginning-of-thing)
|
||||
'sentence (abs arg))))
|
||||
(or (funcall
|
||||
(if (> arg 0) #'treesit-end-of-thing #'treesit-beginning-of-thing)
|
||||
'sentence (abs arg))
|
||||
;; On failure jump to the buffer's end as `forward-sentence' does,
|
||||
;; but no further than the boundary of the current range.
|
||||
(goto-char (if (> arg 0)
|
||||
(min (point-max) (next-single-char-property-change
|
||||
(point) 'treesit-parser))
|
||||
(max (point-min) (previous-single-char-property-change
|
||||
(point) 'treesit-parser)))))))
|
||||
|
||||
(defun treesit-forward-comment (&optional count)
|
||||
"Tree-sitter `forward-comment-function' implementation.
|
||||
|
|
Loading…
Add table
Reference in a new issue