1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Eglot: make markup invisible instead of deleting it (bug#79552)

We use gfm-view-mode to render Markdown before we hand over the string
to ElDoc (which usually put it in a 'special' mode "*eldoc*" buffer).
'gfm-view-mode' adds keymap text properties to make links clickable.  It
also makes some of the markup invisible with a special 'invisible'
property value which is specific to 'gfm-view-mode'.  We used to delete
the latter, therefore breaking the link-clicking.  Simply resetting the
regions with non-nil 'invisible' to 't' instead of deleting them fixes
this.  See also https://github.com/joaotavora/eglot/discussions/1238

* lisp/progmodes/eglot.el: Make invisible markup invisible
instead of deleting it.

* etc/EGLOT-NEWS: Mention bugfix.

Co-authored-by: João Távora <joaotavora@gmail.com>
This commit is contained in:
Spencer Baugh 2025-10-01 17:28:47 -04:00 committed by João Távora
parent 72f3f48d36
commit 3ec87212a4
2 changed files with 14 additions and 3 deletions

View file

@ -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)