GNU bug report logs -
#79426
diagnostic with empty range => preceding char is highlighted
Previous Next
To reply to this bug, email your comments to 79426 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79426
; Package
emacs
.
(Wed, 10 Sep 2025 22:09:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Alan Donovan <adonovan <at> google.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 10 Sep 2025 22:09:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
(from https://github.com/joaotavora/eglot/issues/27#issuecomment-3275571619)
The fix for issue #27 (zero-width ranges) included this code:
;; Fallback to `flymake-diag-region' if server
;; botched the range
(when (= beg end)
(if-let* ((st (plist-get range :start))
(diag-region
(flymake-diag-region
(current-buffer) (1+ (plist-get st :line))
(plist-get st :character))))
(setq beg (car diag-region) end (cdr diag-region))
(eglot--widening
(goto-char (point-min))
(setq beg
(eglot--bol
(1+ (plist-get (plist-get range :start) :line))))
(setq end
(line-end-position
(1+ (plist-get (plist-get range :end) :line)))))))
This causes Emacs to highlight the character before the indicated
range, which is often an irrelevant blank space, instead of the
character after, which is the token of interest. (Gopls' nilness
analyzers publishes zero-width diagnostics.)
Why is that the appropriate fix, as opposed to something as simple as this?
(when (= beg end)
(setq end (1+ end)))
(Aside: "botched" seems like an unnecessarily pejorative: an empty
range is what it is, and sometimes all the information the server has
is the start point of a token.)
There have been two minor changes to that logic since #27 was fixed,
but neither seems relevant to this question:
- 3d9a6f1 Handle case when diagnostic :character is out of range
- 5b62d00 Enable lsp project-wide diagnostics via flymake
I couldn't check for related issues because
https://lists.gnu.org/archive/html/bug-gnu-emacs/ appears to be down.
thanks
alan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79426
; Package
emacs
.
(Thu, 11 Sep 2025 04:50:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 79426 <at> debbugs.gnu.org (full text, mbox):
> Date: Wed, 10 Sep 2025 18:07:56 -0400
> From: Alan Donovan via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> (from https://github.com/joaotavora/eglot/issues/27#issuecomment-3275571619)
>
> The fix for issue #27 (zero-width ranges) included this code:
>
> ;; Fallback to `flymake-diag-region' if server
> ;; botched the range
> (when (= beg end)
> (if-let* ((st (plist-get range :start))
> (diag-region
> (flymake-diag-region
> (current-buffer) (1+ (plist-get st :line))
> (plist-get st :character))))
> (setq beg (car diag-region) end (cdr diag-region))
> (eglot--widening
> (goto-char (point-min))
> (setq beg
> (eglot--bol
> (1+ (plist-get (plist-get range :start) :line))))
> (setq end
> (line-end-position
> (1+ (plist-get (plist-get range :end) :line)))))))
>
> This causes Emacs to highlight the character before the indicated
> range, which is often an irrelevant blank space, instead of the
> character after, which is the token of interest. (Gopls' nilness
> analyzers publishes zero-width diagnostics.)
>
> Why is that the appropriate fix, as opposed to something as simple as this?
>
> (when (= beg end)
> (setq end (1+ end)))
>
> (Aside: "botched" seems like an unnecessarily pejorative: an empty
> range is what it is, and sometimes all the information the server has
> is the start point of a token.)
>
> There have been two minor changes to that logic since #27 was fixed,
> but neither seems relevant to this question:
> - 3d9a6f1 Handle case when diagnostic :character is out of range
> - 5b62d00 Enable lsp project-wide diagnostics via flymake
>
> I couldn't check for related issues because
> https://lists.gnu.org/archive/html/bug-gnu-emacs/ appears to be down.
Thanks, I added João to the discussion.
This bug report was last modified 2 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.