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)
committerYuan Fu <casouri@gmail.com>
Sat, 14 Sep 2024 07:28:23 +0000 (00:28 -0700)
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

index ee83486b92a10253de20e7661dc628a07a9d9b18..2b43c505dfa8aeec8e718b77c26326af024385bd 100644 (file)
@@ -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.  */