diff --git a/etc/EGLOT-NEWS b/etc/EGLOT-NEWS index 6505a6d8567..23104edd5d6 100644 --- a/etc/EGLOT-NEWS +++ b/etc/EGLOT-NEWS @@ -54,6 +54,12 @@ by the LSP server pertain. This helps in skipping useless or harmful updates, avoiding flakiness with code actions and flickering overlays when the buffer is changed. +** Markdown links migrating to *eldoc* buffer now clickable (bug#79552) + +Eglot now preserves crucial properties in the Markdown documentation +provided by the LSP server, fixing a longstanding bug with clickable +hyperlinks. See also github#1238. + * Changes in Eglot 1.18 (20/1/2025) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index b35d5e15e6c..6a7edef08b3 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2018,7 +2018,7 @@ Doubles as an indicator of snippet support." (unless (bound-and-true-p yas-minor-mode) (yas-minor-mode 1)) (apply #'yas-expand-snippet args))))) - (defun eglot--format-markup (markup &optional mode) +(defun eglot--format-markup (markup &optional mode) "Format MARKUP according to LSP's spec. MARKUP is either an LSP MarkedString or MarkupContent object." (let (string render-mode language) @@ -2050,9 +2050,14 @@ MARKUP is either an LSP MarkedString or MarkupContent object." (goto-char (point-min)) (let ((inhibit-read-only t)) (when (fboundp 'text-property-search-forward) + ;; If `render-mode' is `gfm-view-mode', the `invisible' + ;; regions are set to `markdown-markup'. Set them to 't' + ;; instead, since this has actual meaning in the "*eldoc*" + ;; buffer where we're taking this string (#bug79552). (while (setq match (text-property-search-forward 'invisible)) - (delete-region (prop-match-beginning match) - (prop-match-end match))))) + (put-text-property (prop-match-beginning match) + (prop-match-end match) + 'invisible t)))) (string-trim (buffer-string)))))) (defun eglot--read-server (prompt &optional dont-if-just-the-one)