]> git.eshelyaron.com Git - emacs.git/commitdiff
Revert "Read more on each call to treesit's buffer reader"
authorYuan Fu <casouri@gmail.com>
Sat, 14 Sep 2024 05:53:06 +0000 (22:53 -0700)
committerEshel Yaron <me@eshelyaron.com>
Sat, 14 Sep 2024 20:32:18 +0000 (22:32 +0200)
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.

(cherry picked from commit 76faf7e60910ffc29b134fa4d16e3d8c176097a7)

src/treesit.c

index 4a910ddeba8cfc43a3edf3816f9052a89c529790..326015cd7aa09c7ed7d177747b2a913045e66157 100644 (file)
@@ -1231,13 +1231,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.  */