'((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)))
buffer, Emacs will move the start of the query range backward by
START amount, and the end of the query range by END amount. Both
START and END should be positive integers or 0. This doesn't
-affect the fontified range.
-
-Sometimes, querying on some parser with a restricted range
-returns nodes not in that range but before it, which breaks
-fontification. Major modes can adjust this variable as a
-temporarily fix.")
+affect the fontified range.")
(defvar-local treesit-font-lock-feature-list nil
"A list of lists of feature symbols.
/* Set query range. */
if (!NILP (beg) && !NILP (end))
{
- EMACS_INT beg_byte = XFIXNUM (beg);
- EMACS_INT end_byte = XFIXNUM (end);
+ EMACS_INT beg_byte = buf_charpos_to_bytepos (current_buffer,
+ XFIXNUM (beg));
+ EMACS_INT end_byte = buf_charpos_to_bytepos (current_buffer,
+ XFIXNUM (end));
/* We never let tree-sitter run on buffers too large, so these
assertion should never hit. */
eassert (beg_byte - visible_beg <= UINT32_MAX);
eassert (end_byte - visible_beg <= UINT32_MAX);
- ts_query_cursor_set_byte_range (cursor, (uint32_t) beg_byte - visible_beg,
- (uint32_t) end_byte - visible_beg);
+ ts_query_cursor_set_byte_range (cursor,
+ (uint32_t) (beg_byte - visible_beg),
+ (uint32_t) (end_byte - visible_beg));
}
/* Execute query. */