]> git.eshelyaron.com Git - emacs.git/commit
Correctly refontify changed region in tree-sitter modes (bug#66732)
authorYuan Fu <casouri@gmail.com>
Sun, 17 Dec 2023 01:15:04 +0000 (17:15 -0800)
committerEshel Yaron <me@eshelyaron.com>
Tue, 2 Jan 2024 07:15:16 +0000 (08:15 +0100)
commita8f6d735ad5043922d7945a1e4a2a9ccc3306d87
tree1b6ffca52fa2cced5052f6cad64ffad94bb9be0b
parent5d8568e00c2c36ce2fbc7554635868826ec5009a
Correctly refontify changed region in tree-sitter modes (bug#66732)

We already have treesit--font-lock-notifier that should mark changed
regions to be refontified, but it's called too late in the redsiplay &
fontification pipeline.  Here we add treesit--pre-redisplay that
forces reparse and calls notifier functions in
pre-redisplay-functions, which is early enough for the marking to take
effect.

Similarly, we force reparse in
syntax-propertize-extend-region-functions so syntax-ppss will have the
up-to-date syntax information when it scans the buffer text.  We also
record the lowest start position of the affected regions, and make
sure next syntex-propertize starts from that position.

* lisp/treesit.el (treesit--pre-redisplay-tick):
(treesit--syntax-propertize-start): New variable.
(treesit--syntax-propertize-notifier):
(treesit--pre-redisplay):
(treesit--pre-syntax-ppss): New functions.
(treesit-major-mode-setup): Add hooks.

* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): Remove notifier.
(ruby-ts--parser-after-change): Remove notifier function.

(cherry picked from commit 6ea507296a7e8bd55df8961793b02cf54d0f3c72)
lisp/progmodes/ruby-ts-mode.el
lisp/treesit.el