[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#66732: tree-sitter fontification doesn't update multi-line syntax re
From: |
Stefan Monnier |
Subject: |
bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably |
Date: |
Sat, 16 Dec 2023 10:22:41 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> diff --git a/lisp/treesit.el b/lisp/treesit.el
> index 8a07f5023a9..a6ca6334133 100644
> --- a/lisp/treesit.el
> +++ b/lisp/treesit.el
> @@ -1080,13 +1080,39 @@ treesit--font-lock-notifier
> "Ensures updated parts of the parse-tree are refontified.
> RANGES is a list of (BEG . END) ranges, PARSER is the tree-sitter
> parser notifying of the change."
> - (with-current-buffer (treesit-parser-buffer parser)
> - (dolist (range ranges)
> - (when treesit--font-lock-verbose
> - (message "Notifier received range: %s-%s"
> - (car range) (cdr range)))
> - (with-silent-modifications
> - (put-text-property (car range) (cdr range) 'fontified nil)))))
> + ;; (with-current-buffer (treesit-parser-buffer parser)
> + ;; (dolist (range ranges)
> + ;; (when treesit--font-lock-verbose
> + ;; (message "Notifier received range: %s-%s"
> + ;; (car range) (cdr range)))
> + ;; (with-silent-modifications
> + ;; (put-text-property (car range) (cdr range) 'fontified nil))))
> + )
> +
> +(defun treesit--font-lock-extend-region ()
> + (treesit-update-ranges)
> + (dolist (parser (treesit-parser-list nil nil t))
> + (treesit-parser-root-node parser))
> + (let ((old-beg font-lock-beg)
> + (old-end font-lock-end))
> + (dolist (parser (treesit-parser-list nil nil t))
> + (when-let ((table treesit--parser-updated-ranges)
> + (ranges (gethash parser table)))
> + (dolist (range ranges)
> + (setq font-lock-beg (max (min font-lock-beg (car range))
> (point-min)))
> + (setq font-lock-end (min (max font-lock-end (cdr range))
> (point-max))))))
> + (put-text-property font-lock-beg font-lock-end 'fontified nil)
> + (message "extend region: %s-%s %s-%s this-command: %s" old-beg old-end
> + font-lock-beg font-lock-end this-command)))
Hmm... This `put-text-property` can't be right.
Can you trace `font-lock-fontify-region` and
`font-lock-default-fontify-region` to check that they correctly return
the proper (extended) bounds of the region they (re)fontified?
Stefan
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, (continued)
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Dmitry Gutov, 2023/12/12
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Yuan Fu, 2023/12/12
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Stefan Monnier, 2023/12/12
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Yuan Fu, 2023/12/13
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Stefan Monnier, 2023/12/13
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Dmitry Gutov, 2023/12/13
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Yuan Fu, 2023/12/14
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Dmitry Gutov, 2023/12/14
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Yuan Fu, 2023/12/15
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Yuan Fu, 2023/12/16
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably,
Stefan Monnier <=
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Stefan Monnier, 2023/12/16
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Dmitry Gutov, 2023/12/16
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Stefan Monnier, 2023/12/16
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Yuan Fu, 2023/12/16
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Stefan Monnier, 2023/12/16
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Dmitry Gutov, 2023/12/16
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Yuan Fu, 2023/12/16
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Dmitry Gutov, 2023/12/17
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Yuan Fu, 2023/12/18
- bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably, Dmitry Gutov, 2023/12/19