diff options
author | Yuan Fu <casouri@gmail.com> | 2022-12-05 18:37:47 -0800 |
---|---|---|
committer | Yuan Fu <casouri@gmail.com> | 2022-12-05 19:56:47 -0800 |
commit | c26fe45cb8046eecaf3a74e3e7d4bc62ab511a8c (patch) | |
tree | 3cdc961f440fa79f0d9c48901c9f961d525787a8 /lisp/textmodes | |
parent | 318bf42b410d4a8ecf0e8ff64280cfd655884877 (diff) | |
download | emacs-c26fe45cb8046eecaf3a74e3e7d4bc62ab511a8c.tar.gz |
Fix treesit-query-capture
Before this change Ftreesit_query_capture doesn't convert character
position to byte position for BEG and END parameters. I observed
fontification issue in css files but couldn't figure out why, now I
know :-)
I decide to keep treesit--font-lock-query-expand-range, since it might
provide a escape hatch for problems we discover in the future, and it
should be very cheap so no downside of keeping it.
* lisp/textmodes/css-mode.el (css-ts-mode): Stop setting
treesit--font-lock-query-expand-range.
* lisp/treesit.el (treesit--font-lock-query-expand-range): Update
docstring.
* src/treesit.c (Ftreesit_query_capture): Convert BEG and END to byte
position. Also added parentheses wround "beg_byte - visible_beg" in
the call to ts_query_cursor_set_byte_range (i.e., style change).
Diffstat (limited to 'lisp/textmodes')
-rw-r--r-- | lisp/textmodes/css-mode.el | 5 |
1 files changed, 0 insertions, 5 deletions
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index b82886e3974..8a66986dc6f 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1839,11 +1839,6 @@ can also be used to fill comments. '((selector comment query keyword) (property constant string) (error variable function operator bracket))) - ;; Tree-sitter-css, for whatever reason, cannot reliably return - ;; the captured nodes in a given range (it instead returns the - ;; nodes preceding range). Before this is fixed in - ;; tree-sitter-css, use this heuristic as a temporary fix. - (setq-local treesit--font-lock-query-expand-range (cons 80 80)) (setq-local imenu-create-index-function #'css--treesit-imenu) (setq-local which-func-functions nil) (treesit-major-mode-setup))) |