[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 4bd06ce2a9 2/3: Fix call to treesit_record_change in insdel.c
From: |
Yuan Fu |
Subject: |
emacs-29 4bd06ce2a9 2/3: Fix call to treesit_record_change in insdel.c |
Date: |
Thu, 26 Jan 2023 02:52:09 -0500 (EST) |
branch: emacs-29
commit 4bd06ce2a9fa1601aff5a5fcab7411e5fce20d28
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Fix call to treesit_record_change in insdel.c
The start position of the change shouldn't be PT_BYTE, IIUC PT_BYTE is
actually the end position.
* src/insdel.c (insert_from_buffer): Move to here.
(insert_from_buffer_1): Remove call to treesit_record_change.
---
src/insdel.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/insdel.c b/src/insdel.c
index b51767bf52..33dea569b2 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1175,9 +1175,19 @@ insert_from_buffer (struct buffer *buf,
{
ptrdiff_t opoint = PT;
+#ifdef HAVE_TREE_SITTER
+ ptrdiff_t obyte = PT_BYTE;
+#endif
+
insert_from_buffer_1 (buf, charpos, nchars, inherit);
signal_after_change (opoint, 0, PT - opoint);
update_compositions (opoint, PT, CHECK_BORDER);
+
+#ifdef HAVE_TREE_SITTER
+ eassert (PT_BYTE >= 0);
+ eassert (PT_BYTE >= obyte);
+ treesit_record_change (obyte, obyte, PT_BYTE);
+#endif
}
static void
@@ -1305,12 +1315,6 @@ insert_from_buffer_1 (struct buffer *buf,
/* Insert those intervals. */
graft_intervals_into_buffer (intervals, PT, nchars, current_buffer, inherit);
-#ifdef HAVE_TREE_SITTER
- eassert (outgoing_nbytes >= 0);
- eassert (PT_BYTE >= 0);
- treesit_record_change (PT_BYTE, PT_BYTE, PT_BYTE + outgoing_nbytes);
-#endif
-
adjust_point (nchars, outgoing_nbytes);
}