|
From: | Dmitry Gutov |
Subject: | bug#61369: Problem with keeping tree-sitter parse tree up-to-date |
Date: | Sat, 18 Feb 2023 02:11:22 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 |
On 18/02/2023 00:32, Yuan Fu wrote:
Thank you very much! I thought that clipping the change into the fixed visible range, and rely on treesit_sync_visible_region to add back the clipped “tail” when we extend the visible range would be equivalent to not clipping, but I guess clipping and re-adding affects how incremental parsing works inside tree-sitter.
It seems like the "repairing" sync used a different range, one that didn't include the character number 68 inserted from the beginning.
It just synced the 1 or 2 characters at the end of the buffer, the difference between the computed visible_end and the actual BUF_ZV_BYTE.
I don’t think this change would have any adverse effect, because if you think of it, inserting text in a narrowed region always extends the region, rather than pushing text at the end out of the narrowed region. So the right thing to do here is in fact not clipping new_end_offset.
I figured it could be a problem if both old_end_byte and new_end_byte extend past the current restriction.
But I'm not sure whether that could actually happen in practice. The obvious attempts (undo a change outside of the narrowing, or revert the buffer when narrowing is in effect) didn't play out, but I'm not sure whether there is an actual hard limit on modifying the text outside of the current restriction.
I pushed this change.
Thanks. Good to see it make it in.
[Prev in Thread] | Current Thread | [Next in Thread] |