markdown-ts-mode: fix first-item indent (bug#81118)

* lisp/textmodes/markdown-ts-mode.el
(markdown-ts--fontify-unordered-list-marker): Skip leading
whitespace in the node range before applying the display bullet,
since the tree-sitter grammar bundles indent into the first
list_marker_* node.
This commit is contained in:
Rahul Martim Juliato 2026-05-25 15:17:25 -03:00 committed by Eli Zaretskii
parent 07e02917ee
commit 0989625d36

View file

@ -1406,8 +1406,16 @@ If NODE is not in a list, return -1."
"Fontify unordered list marker NODE, show a symbol when markup is hidden. "Fontify unordered list marker NODE, show a symbol when markup is hidden.
OVERRIDE, START, and END are passed through to OVERRIDE, START, and END are passed through to
`treesit-fontify-with-override'." `treesit-fontify-with-override'."
(let* ((node-start (treesit-node-start node)) ;; The tree-sitter markdown grammar includes the leading indentation
;; in the first list_marker_minus/plus/star node of a list, so skip
;; over any leading whitespace to avoid overwriting the indent with
;; the replacement glyph.
(let* ((raw-start (treesit-node-start node))
(node-end (treesit-node-end node)) (node-end (treesit-node-end node))
(node-start (save-excursion
(goto-char raw-start)
(skip-chars-forward " \t" node-end)
(point)))
(face 'markdown-ts-list-marker)) (face 'markdown-ts-list-marker))
(treesit-fontify-with-override node-start node-end face (treesit-fontify-with-override node-start node-end face
override start end) override start end)