From ff4773ed0295fc0c5812136c25a2db0830d49613 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 23 Feb 2026 20:34:15 +0200 Subject: [PATCH] Fix treesit-show-paren-data to match only 2 children nodes or more * lisp/treesit.el (treesit-show-paren-data--categorize): Ignore parent that has less than two children (bug#80475). This ensures the distinct first and last node. --- lisp/treesit.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/treesit.el b/lisp/treesit.el index c018afc1e98..0bc115a3331 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -4370,6 +4370,8 @@ as belonging to the node that ends before POS (by subtracting 1 from POS)." pred (treesit-language-at (if end-p (1- pos) pos))) (treesit-parent-until (treesit-node-at (if end-p (1- pos) pos)) pred))) + (parent (when (and parent (> (treesit-node-child-count parent) 1)) + parent)) (first (when parent (treesit-node-child parent 0))) (first-start (when first (treesit-node-start first))) (first-end (when first (treesit-node-end first)))