[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-30 bf23382f1f2 4/4: Read more on each call to treesit's buffer rea
From: |
Yuan Fu |
Subject: |
emacs-30 bf23382f1f2 4/4: Read more on each call to treesit's buffer reader |
Date: |
Sun, 8 Sep 2024 23:52:53 -0400 (EDT) |
branch: emacs-30
commit bf23382f1f2d6ea072db4e4750f8a345f77a3ef2
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Read more on each call to treesit's buffer reader
* src/treesit.c (treesit_read_buffer): Read until the gap or visible
end, instead of reading a single char.
---
src/treesit.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/treesit.c b/src/treesit.c
index 970754f3c1b..b047f0344cc 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -1225,11 +1225,13 @@ treesit_read_buffer (void *parser, uint32_t byte_index,
beg = NULL;
len = 0;
}
- /* Normal case, read a character. */
+ /* Normal case, read until the gap or visible end. */
else
{
beg = (char *) BUF_BYTE_ADDRESS (buffer, byte_pos);
- len = BYTES_BY_CHAR_HEAD ((int) *beg);
+ ptrdiff_t gap_bytepos = buffer->text->gpt_byte;
+ len = (byte_pos < gap_bytepos)
+ ? gap_bytepos - byte_pos : visible_end - byte_pos;
}
/* We never let tree-sitter to parse buffers that large so this
assertion should never hit. */