]> git.eshelyaron.com Git - emacs.git/commit
Tree-sitter: only update range and reparse for changed ranges
authorYuan Fu <casouri@gmail.com>
Fri, 19 Apr 2024 07:18:03 +0000 (00:18 -0700)
committerEshel Yaron <me@eshelyaron.com>
Sat, 20 Apr 2024 11:10:52 +0000 (14:10 +0300)
commit67ee35b8f63f6e050e7adb1e91eb4eac9053b04b
treefd57553fcda36591fa6084646f417d3173f9bf26
parent5cd404bdc6b0d56327bfc98fdec7b817f850a6cb
Tree-sitter: only update range and reparse for changed ranges

In the very beginning, there's bug#66732, to solve that bug, we added
treesit--pre-redisplay and treesit--syntax-propertize-notifier.
However, to fix bug#66732, we were updating ranges for the whole
buffer which makes Emacs extremely slow when there are a lot of local
parsers in a large buffer.  Then to solve that we introduced a
workaround where we only update ranges in a fixed range around point.

This change fixes the original problem (bug#66732) without using that
workaround.

* lisp/treesit.el (treesit--font-lock-notifier):
(treesit--syntax-propertize-notifier): Remove functions
(treesit--pre-redisplay): Use the new function
treesit-parser-changed-ranges to get the changed ranges of the primary
parser, and only update ranges for those ranges.  Plus do the work of
the removed function.
(treesit-major-mode-setup): Remove setup for the removed functions.

(cherry picked from commit f62c1b4cd00e5b2f1cdc94796cf55d006c3113eb)
lisp/treesit.el