From 5cf50d60041c82deccc4b32a8ecdb1a28b6e8f91 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=ADn?= Date: Sat, 25 Feb 2023 03:07:55 +0100 Subject: [PATCH] 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. --- lisp/treesit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index 045fdf21cba..1decfc3d7cf 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1533,7 +1533,7 @@ Similar to `treesit-indent', but indent a region instead." (dotimes (jdx idx) (let ((anchor (aref meta-vec (* jdx meta-len))) (offset (aref meta-vec (+ 1 (* jdx meta-len))))) - (when offset + (when (and anchor offset) (let ((col (save-excursion (goto-char anchor) (+ offset (current-column))))) -- 2.39.2