]> 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)
committerYuan Fu <casouri@gmail.com>
Sat, 23 Dec 2023 23:03:26 +0000 (15:03 -0800)
commit6ea507296a7e8bd55df8961793b02cf54d0f3c72
tree68b8300f58d4e1002d67a1272ee85a70a0ce6544
parenta4751657389cf47c18416fa5d148ad2a67e14565
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.
lisp/progmodes/ruby-ts-mode.el
lisp/treesit.el