From 0989625d369379599e0b88362704c02fb63422c9 Mon Sep 17 00:00:00 2001 From: Rahul Martim Juliato Date: Mon, 25 May 2026 15:17:25 -0300 Subject: [PATCH] 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. --- lisp/textmodes/markdown-ts-mode.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lisp/textmodes/markdown-ts-mode.el b/lisp/textmodes/markdown-ts-mode.el index e6b01c77b57..b2124b20775 100644 --- a/lisp/textmodes/markdown-ts-mode.el +++ b/lisp/textmodes/markdown-ts-mode.el @@ -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. OVERRIDE, START, and END are passed through to `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-start (save-excursion + (goto-char raw-start) + (skip-chars-forward " \t" node-end) + (point))) (face 'markdown-ts-list-marker)) (treesit-fontify-with-override node-start node-end face override start end)