Received: (at 79426) by debbugs.gnu.org; 11 Sep 2025 04:50:02 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 11 00:50:01 2025 Received: from localhost ([127.0.0.1]:41602 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1uwZFx-0000NB-Cv for submit <at> debbugs.gnu.org; Thu, 11 Sep 2025 00:50:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49866) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uwZFv-0000Mm-Qi for 79426 <at> debbugs.gnu.org; Thu, 11 Sep 2025 00:50:00 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1uwZFq-0003DE-Ay; Thu, 11 Sep 2025 00:49:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=mDTrAS+sIJZlCMWos6AjSE6ebOJM5FC6IzRcRJxpiEM=; b=TXCpzwC0M9wD9xybTTHS xLFQtKrvywKAsppLdTvA377NAPaACxuNEy+SbtX0y1wBOo99MC3sAJAXg1FnD/PCVxt8/vBLcEXkt sa0edW573zswjReWiOfn0Vhg2No7jGLbFYuA3Ul8/0MO01L7/XAvnMrfA8xUBzAg0xMsjtjD/vuuL kXHUBBKgeuStYNX9zNcjmNDeMM8+j+Jf6PGcFZU+PX/5bpnuEZY6mOgtJqgD+1Zuf/OzK+UFjoE9Q RQB7jxYQpXSVTfstflCQMJqEerj9aidq7XhHGOv8a7D61K9mdVrV1M7i4KL1ON+z8M0tAybB1mZ+7 ukVqZCZ78xX/rw==; Date: Thu, 11 Sep 2025 07:49:52 +0300 Message-Id: <86frctvbin.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Alan Donovan <adonovan@HIDDEN>, =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN> In-Reply-To: <CAPVWWDWORKGynC=jcq80J2ZJEEwmO=dCtZN8OVvYPH0uEWL7PA@HIDDEN> (bug-gnu-emacs@HIDDEN) Subject: Re: bug#79426: diagnostic with empty range => preceding char is highlighted References: <CAPVWWDWORKGynC=jcq80J2ZJEEwmO=dCtZN8OVvYPH0uEWL7PA@HIDDEN> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79426 Cc: 79426 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > 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@HIDDEN> > > (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.
bug-gnu-emacs@HIDDEN:bug#79426; Package emacs.
Full text available.
Received: (at submit) by debbugs.gnu.org; 10 Sep 2025 22:08:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 10 18:08:24 2025
Received: from localhost ([127.0.0.1]:40659 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1uwSzH-0001ry-Mr
for submit <at> debbugs.gnu.org; Wed, 10 Sep 2025 18:08:24 -0400
Received: from lists.gnu.org ([2001:470:142::17]:60208)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.84_2) (envelope-from <adonovan@HIDDEN>)
id 1uwSzF-0001r2-QJ
for submit <at> debbugs.gnu.org; Wed, 10 Sep 2025 18:08:22 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <adonovan@HIDDEN>)
id 1uwSz6-00040t-H6
for bug-gnu-emacs@HIDDEN; Wed, 10 Sep 2025 18:08:12 -0400
Received: from mail-il1-x130.google.com ([2607:f8b0:4864:20::130])
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.90_1) (envelope-from <adonovan@HIDDEN>)
id 1uwSz4-0007eH-Ro
for bug-gnu-emacs@HIDDEN; Wed, 10 Sep 2025 18:08:12 -0400
Received: by mail-il1-x130.google.com with SMTP id
e9e14a558f8ab-408c236c500so34885ab.1
for <bug-gnu-emacs@HIDDEN>; Wed, 10 Sep 2025 15:08:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=google.com; s=20230601; t=1757542088; x=1758146888; darn=gnu.org;
h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
:date:message-id:reply-to;
bh=Mx2djxGyS4ylj0LD0cE3FVxEaQpFq2VFmZfqECF9xZY=;
b=bRRL3badftoCduJa1/rCnhUYl8ykghA628o30VDuvJWd5l2ESeyw+0WXeMbVL6eKRH
6fReGcqcXzzWc6UhN/H8m4GODvmiD2RDso2qFKL4Q8dC05DUcIy5vsUy7zAgpiaNAL4P
EvGsztoE0liC1oJRzR++p0yiiY73lqnwe3xXOohXpulKXtI+nltJr5Gg9L0kZrPpELKL
3LlAGMMaEWaKcu6iJgtyiQEABThuYZAnI1OYcLrZeZD/UOfncmcKdfljn5fRor1BLfgq
ImtXR/gGEDtgO4Pftdrnd0EsnstlD1EZXl9nHzOL7vwiBbmd9ATeJBMb9jd7QMKGDC49
eHYQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1757542088; x=1758146888;
h=to:subject:message-id:date:from:mime-version:x-gm-message-state
:from:to:cc:subject:date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wed, 10 Sep 2025
15:08:07 -0700 (PDT)
MIME-Version: 1.0
From: Alan Donovan <adonovan@HIDDEN>
Date: Wed, 10 Sep 2025 18:07:56 -0400
X-Gm-Features: Ac12FXyrZzZxP2bHucb629ME73x3mPDxe-VJrOOW1WtL0h5Eh0JySOvKHAvaHks
Message-ID: <CAPVWWDWORKGynC=jcq80J2ZJEEwmO=dCtZN8OVvYPH0uEWL7PA@HIDDEN>
Subject: diagnostic with empty range => preceding char is highlighted
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Received-SPF: pass client-ip=2607:f8b0:4864:20::130;
envelope-from=adonovan@HIDDEN; helo=mail-il1-x130.google.com
X-Spam_score_int: -175
X-Spam_score: -17.6
X-Spam_bar: -----------------
X-Spam_report: (-17.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001,
DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5,
USER_IN_DEF_SPF_WL=-7.5 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)
(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
Alan Donovan <adonovan@HIDDEN>:bug-gnu-emacs@HIDDEN.
Full text available.bug-gnu-emacs@HIDDEN:bug#79426; Package emacs.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.