diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/treesit.el | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el index 7205e43916d..e53d5d53bd0 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1341,10 +1341,10 @@ and returns (ANCHOR . OFFSET). BOL is the position of the beginning of the line; NODE is the -\"largest\" node that starts at BOL; PARENT is its parent; ANCHOR -is a point (not a node), and OFFSET is a number. Emacs finds the -column of ANCHOR and adds OFFSET to it as the final indentation -of the current line.") +\"largest\" node that starts at BOL (and isn't a root node); +PARENT is its parent; ANCHOR is a point (not a node), and OFFSET +is a number. Emacs finds the column of ANCHOR and adds OFFSET to +it as the final indentation of the current line.") (defun treesit--indent-1 () "Indent the current line. @@ -1362,10 +1362,13 @@ Return (ANCHOR . OFFSET). This function is used by ((treesit-language-at (point)) (treesit-node-at bol (treesit-language-at (point)))) (t (treesit-node-at bol)))) + (root (treesit-parser-root-node + (treesit-node-parser smallest-node))) (node (treesit-parent-while smallest-node (lambda (node) - (eq bol (treesit-node-start node)))))) + (and (eq bol (treesit-node-start node)) + (not (treesit-node-eq node root))))))) (let* ((parser (if smallest-node (treesit-node-parser smallest-node) |