aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/treesit.el34
1 files changed, 24 insertions, 10 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 6809f1ec086..752ab73a473 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -4255,8 +4255,7 @@ For BOUND, MOVE, BACKWARD, LOOKING-AT, see the descriptions in
4255 (if (bobp) (point) (1- (point))) pred)) 4255 (if (bobp) (point) (1- (point))) pred))
4256 (end (when thing (treesit-node-end thing))) 4256 (end (when thing (treesit-node-end thing)))
4257 (last (when thing (treesit-node-child thing -1))) 4257 (last (when thing (treesit-node-child thing -1)))
4258 (beg (if last (treesit-node-start last) 4258 (beg (treesit-node-start (or last thing))))
4259 (if (bobp) (point) (1- (point))))))
4260 (when (and thing (eq (point) end)) 4259 (when (and thing (eq (point) end))
4261 (set-match-data (list beg end)) 4260 (set-match-data (list beg end))
4262 t))) 4261 t)))
@@ -4313,14 +4312,29 @@ For BOUND, MOVE, BACKWARD, LOOKING-AT, see the descriptions in
4313 4312
4314(defun treesit-hs-inside-comment-p () 4313(defun treesit-hs-inside-comment-p ()
4315 "Tree-sitter implementation of `hs-inside-comment-predicate'." 4314 "Tree-sitter implementation of `hs-inside-comment-predicate'."
4316 (let* ((comment-pred 4315 (when-let* ((comment-pred
4317 (if (treesit-thing-defined-p 'comment (treesit-language-at (point))) 4316 (if (treesit-thing-defined-p 'comment (treesit-language-at (point)))
4318 'comment "\\`comment\\'")) 4317 'comment "\\`comment\\'"))
4319 (thing (or (treesit-thing-at (point) comment-pred) 4318 (thing (or (treesit-thing-at (point) comment-pred)
4320 (unless (bobp) 4319 (unless (bobp)
4321 (treesit-thing-at (1- (point)) comment-pred))))) 4320 (treesit-thing-at (1- (point)) comment-pred))))
4322 (when thing 4321 (beg (treesit-node-start thing))
4323 (list (treesit-node-start thing) (treesit-node-end thing))))) 4322 (end (treesit-node-end thing)))
4323 (unless (and (fboundp 'hs-hideable-region-p) (hs-hideable-region-p beg end))
4324 (save-excursion
4325 (goto-char beg)
4326 (while (and (skip-chars-forward "[:blank:]")
4327 (when-let* ((c (treesit-thing-at (point) comment-pred)))
4328 (setq beg (treesit-node-start c)))
4329 (not (bobp))
4330 (forward-line -1)))
4331 (goto-char beg)
4332 (while (and (skip-chars-forward "[:blank:]")
4333 (when-let* ((c (treesit-thing-at (point) comment-pred)))
4334 (setq end (treesit-node-end c)))
4335 (not (eobp))
4336 (forward-line 1)))))
4337 (list beg end)))
4324 4338
4325;;; Show paren mode 4339;;; Show paren mode
4326 4340