Check the anchor along with the offset in treesit-indent-region

* lisp/treesit.el (treesit-indent-region): To compute a valid column,
having a non-nil offset is not enough, we need a non-nil anchor as
well.
This commit is contained in:
Daniel Martín 2023-02-25 03:07:55 +01:00 committed by Yuan Fu
parent 497018dd5c
commit 5cf50d6004
No known key found for this signature in database
GPG key ID: 56E19BC57664A442

View file

@ -1533,7 +1533,7 @@ Similar to `treesit-indent', but indent a region instead."
(dotimes (jdx idx) (dotimes (jdx idx)
(let ((anchor (aref meta-vec (* jdx meta-len))) (let ((anchor (aref meta-vec (* jdx meta-len)))
(offset (aref meta-vec (+ 1 (* jdx meta-len))))) (offset (aref meta-vec (+ 1 (* jdx meta-len)))))
(when offset (when (and anchor offset)
(let ((col (save-excursion (let ((col (save-excursion
(goto-char anchor) (goto-char anchor)
(+ offset (current-column))))) (+ offset (current-column)))))