]> git.eshelyaron.com Git - emacs.git/commit
Further tweak tree-sitter fontification heuristics
authorYuan Fu <casouri@gmail.com>
Mon, 21 Nov 2022 18:52:55 +0000 (10:52 -0800)
committerYuan Fu <casouri@gmail.com>
Mon, 21 Nov 2022 18:52:55 +0000 (10:52 -0800)
commit0cbb7d3bd098e80b58457cb58125cc67e56415a2
tree8d8cc54c4cf461b49cf3a42c29a4caca5a23c2d4
parentaa6958c04e6912f0fe58e658c91459db8f86b08a
Further tweak tree-sitter fontification heuristics

So it turns out the slowness observed in bug#59415 is not due to the
size, but the strangely tall tree.  Adjust the heuristic to DTRT:
don't enable the heuristic by default or when buffer is large, enable
when query is abnormally slow.  We could do some clever thing that
calibrates a base reading for the query time instead of using a
hard-coded value, but it doesn't seem necessary.

* lisp/treesit.el (treesit--font-lock-fast-mode): New variable.
(treesit-font-lock-fontify-region): Don't activate heuristic by
default (reasons in comments).  Measure the query time and activate
the fast mode if query time is long.
lisp/treesit.el