[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold 7312871386 2/2: fix: line comment mode
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold 7312871386 2/2: fix: line comment mode |
Date: |
Thu, 25 Jul 2024 19:00:55 -0400 (EDT) |
branch: elpa/treesit-fold
commit 7312871386e4b525a0ced6a03dc33062cb27f573
Author: JenChieh <jcs090218@gmail.com>
Commit: JenChieh <jcs090218@gmail.com>
fix: line comment mode
---
treesit-fold-util.el | 12 ++++++++++++
treesit-fold.el | 4 ++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/treesit-fold-util.el b/treesit-fold-util.el
index 85a5010c18..9b8fccbff7 100644
--- a/treesit-fold-util.el
+++ b/treesit-fold-util.el
@@ -143,6 +143,18 @@ Optional argument TRIM, see function
`treesit-fold--get-face'."
(goto-char pos)
(current-indentation))
+(defun treesit-fold--node-start-position (node)
+ "Return NODE's start position."
+ (save-excursion
+ (goto-char (treesit-node-start node))
+ (cons (line-number-at-pos) (current-column))))
+
+(defun treesit-fold--node-end-position (node)
+ "Return NODE's end position."
+ (save-excursion
+ (goto-char (treesit-node-end node))
+ (cons (line-number-at-pos) (current-column))))
+
;;
;; (@* "Math" )
;;
diff --git a/treesit-fold.el b/treesit-fold.el
index b1dcf958ad..4269825893 100644
--- a/treesit-fold.el
+++ b/treesit-fold.el
@@ -598,13 +598,13 @@ then return the last iterated node.
Argument NEXT is a boolean type. If non-nil iterate forward; otherwise iterate
in backward direction."
(let* ((iter-node node) (last-node node)
- (last-line (treesit-node-start node)) line text break
+ (last-line (treesit-fold--node-start-position node)) line text break
(line-range 1) (last-line-range 1) max-line-range
(indentation (treesit-fold--indentation (treesit-node-start
iter-node)))
next-indentation)
(while (and iter-node (not break))
(setq text (string-trim (treesit-node-text iter-node))
- line (treesit-node-start iter-node)
+ line (treesit-fold--node-start-position iter-node)
line-range (1+ (treesit-fold--count-matches "\n" text))
max-line-range (max line-range last-line-range)
next-indentation (treesit-fold--indentation (treesit-node-start
iter-node)))