From 76faf7e60910ffc29b134fa4d16e3d8c176097a7 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Fri, 13 Sep 2024 22:53:06 -0700 Subject: [PATCH] Revert "Read more on each call to treesit's buffer reader" This reverts commit bf23382f1f2d6ea072db4e4750f8a345f77a3ef2. We move around the gap, narrow regions, ralloc, etc, and don't have a way to invalidate previously given range. So tree-sitter can't be given the full range. --- src/treesit.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/treesit.c b/src/treesit.c index ee83486b92a..2b43c505dfa 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -1228,13 +1228,11 @@ treesit_read_buffer (void *parser, uint32_t byte_index, beg = NULL; len = 0; } - /* Normal case, read until the gap or visible end. */ + /* Normal case, read a character. */ else { beg = (char *) BUF_BYTE_ADDRESS (buffer, byte_pos); - ptrdiff_t gap_bytepos = BUF_GPT_BYTE (buffer); - len = (byte_pos < gap_bytepos) - ? gap_bytepos - byte_pos : visible_end - byte_pos; + len = BYTES_BY_CHAR_HEAD ((int) *beg); } /* We never let tree-sitter to parse buffers that large so this assertion should never hit. */