-
Notifications
You must be signed in to change notification settings - Fork 75
Description
In many, if not all supported languages, tree-sitter-hl-mode's font locking does not honor the :extend attribute of a face. The :extend face attribute is used to send a highlight past the newline character in a line.
The easiest way to see this is to produce a // comment in a mode that supports it, such as c-mode. Set the font-lock-comment-face and tree-sitter-hl-face:comment :background to a color other than the default background. Then, observe as comments stop at the newline instead of the end of the frame.
tree-sitter-hl-mode Disabled (no bug)
tree-sitter-hl-mode Enabled (bug)
To reproduce this issue:
- launch emacs 29.1 with
emacs -q --load repro.el(code is below). - Create a blank c file, ensuring c-mode is set. Add a
//comment to any line and hit enter. - Observe the comment terminates at the newline (before the right side of the frame).
- Type
M-xtree-sitter-hl-mode. Observe the comment goes to the right side of the frame.
Languages this bug exists in
Not a complete list, but:
- c
- c++
- javascript
- rust (via rustic)
- bash
- python
- ruby
repro.el
;;
;; repro.el
(custom-set-faces
'(font-lock-comment-face ((t (:background "darkblue" :foreground "yellow" :extend t)))))
(custom-set-faces
'(tree-sitter-hl-face:comment ((t (:inherit font-lock-comment-face)))))
;; comments look like this
;;
;; tree-sitter
;;
(defvar bootstrap-version)
(setq straight-repository-branch "master")
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(require 'package)
(use-package tree-sitter
:straight t
:config
(global-tree-sitter-mode)
:hook ((python-mode
rustic-mode
c-mode cc-mode
go-mode
typescript-mode
javascript-mode) . tree-sitter-hl-mode)
)
(use-package tree-sitter-langs
:straight t
:ensure t
:after tree-sitter
)
(require 'tree-sitter-hl)
Note that the same bug was also reported at emacs-tree-sitter/tree-sitter-langs#302. Apologies for the inconvenience of a double-report: I am finding it a little challenging to track down the maintainer of tree-sitter-hl.el for the report, on github.

