Fix tree-sitter local parser overlay cleanup routine
Sorry for sneaking in a sizable commit so late. But I just found out
about this bug and it has to be fixed. Before this change, we weren't
properly cleaning up overlays that store local parsers. And in the case
of doxygen local parser in C files, the doxygen local parser overlay
sometimes bleeds out of comments and into other code, and interferes
with font-lock and indentation.
This commit adds a cleanup function that'll cleanup any overlays that
aren't being used. I tested with doxygen in C files and everything
works smoothly now, including tricky tests like removing the ending "*/"
of a doxygen comment and adding it back.
The idea is simple, at the end of each call to (treesit-update-ranges
BEG END), we remove any overlay within BEG and END that wasn't touched
by the range setting code.
* lisp/treesit.el (treesit--cleanup-local-range-overlays): New function.
(treesit--update-ranges-local): Remove code for cleaning up zero-length
overlays since we have the cleanup function now.
(treesit-update-ranges): Wrap the function body inside a let form, which
defines modified-tick; and add a call to
treesit--cleanup-local-range-overlays at the very end.
(cherry picked from commit
b8c05d73a1105851bbe9871d6a64efc06ddc5b6e)