diff options
| author | Yuan Fu | 2022-12-05 18:37:47 -0800 |
|---|---|---|
| committer | Yuan Fu | 2022-12-05 19:56:47 -0800 |
| commit | c26fe45cb8046eecaf3a74e3e7d4bc62ab511a8c (patch) | |
| tree | 3cdc961f440fa79f0d9c48901c9f961d525787a8 /lisp/textmodes | |
| parent | 318bf42b410d4a8ecf0e8ff64280cfd655884877 (diff) | |
| download | emacs-c26fe45cb8046eecaf3a74e3e7d4bc62ab511a8c.tar.gz emacs-c26fe45cb8046eecaf3a74e3e7d4bc62ab511a8c.zip | |
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. | |||
| 1839 | '((selector comment query keyword) | 1839 | '((selector comment query keyword) |
| 1840 | (property constant string) | 1840 | (property constant string) |
| 1841 | (error variable function operator bracket))) | 1841 | (error variable function operator bracket))) |
| 1842 | ;; Tree-sitter-css, for whatever reason, cannot reliably return | ||
| 1843 | ;; the captured nodes in a given range (it instead returns the | ||
| 1844 | ;; nodes preceding range). Before this is fixed in | ||
| 1845 | ;; tree-sitter-css, use this heuristic as a temporary fix. | ||
| 1846 | (setq-local treesit--font-lock-query-expand-range (cons 80 80)) | ||
| 1847 | (setq-local imenu-create-index-function #'css--treesit-imenu) | 1842 | (setq-local imenu-create-index-function #'css--treesit-imenu) |
| 1848 | (setq-local which-func-functions nil) | 1843 | (setq-local which-func-functions nil) |
| 1849 | (treesit-major-mode-setup))) | 1844 | (treesit-major-mode-setup))) |