Subject: bug#73355: 29.4; eglot-rename reports success when it shouldn't

From: João Távora <[email-masked]>
Date: Sat, 2 Nov 2024 13:26:13 +0000

Sorry for the silence, but I don't have time to work on this right
now, and I don't find the issue serious enough to warrant urgency.
In fact, it could be argued that this isn't an issue at all.  If I give
someone no work to do, they might well announce that they have
done all the work I have given them.

But someone can propose a patch to Eglot that detects when the
changes proposed by the server are an empty set and report
something that indicates that somehow.  Or instead of "rename
successful", Eglot could report the more laconic "All server changes
performed".  Or not report anything at all.

João

On Sat, Nov 2, 2024 at 11:43 AM Eli Zaretskii <[email-masked]> wrote:
>
> Ping! Ping! Ping!
>
> > Cc: [email-masked]
> > Date: Sat, 19 Oct 2024 10:03:06 +0300
> > From: Eli Zaretskii <[email-masked]>
> >
> > Ping! Ping!
> >
> > > Cc: [email-masked]
> > > Date: Sat, 05 Oct 2024 12:57:20 +0300
> > > From: Eli Zaretskii <[email-masked]>
> > >
> > > Ping!
> > >
> > > > From: Joost Kremers <[email-masked]>
> > > > Cc: Eli Zaretskii <[email-masked]>,  [email-masked]
> > > > Date: Sun, 22 Sep 2024 00:46:04 +0200
> > > >
> > > > On Sat, Sep 21 2024, João Távora wrote:
> > > > > I have this some version of this server somewhere, maybe I can reproduce,
> > > > > but as always better to follow the instructions in the manual
> > > > > https://joaotavora.github.io/eglot/#Troubleshooting-Eglot and give the
> > > > > remaining items of a full MRE.
> > > >
> > > > OK, here goes:
> > > >
> > > > 1. The relevant lines from the events buffer (apologies for the long lines):
> > > >
> > > > ```
> > > > [jsonrpc] e[00:13:52.047] --> textDocument/rename[27] {"jsonrpc":"2.0","id":27,"method":"textDocument/rename","params":{"textDocument":{"uri":"file:///home/joost/Projects/Python/pyscratch/src/search.py"},"position":{"line":88,"character":29},"newName":"seq"}}
> > > > [jsonrpc] e[00:13:52.049]   <-- textDocument/rename[27] #[0 "\300\301\302\303\304\305\257\6\207" [:id 27 :jsonrpc "2.0" :result nil] 14]
> > > > ```
> > > >
> > > > Contrast this with a call to 'eglot-rename' that *does* yield changes:
> > > >
> > > > ```
> > > > [jsonrpc] e[00:16:34.228] --> textDocument/rename[68] {"jsonrpc":"2.0","id":68,"method":"textDocument/rename","params":{"textDocument":{"uri":"file:///home/joost/Projects/Python/pyscratch/src/search.py"},"position":{"line":87,"character":8},"newName":"arr"}}
> > > > [jsonrpc] e[00:16:34.235]   <-- textDocument/rename[68] #[0 "\323\312\324\325\326\327\313\330\313\302\303\304\305\306\307\300\331\301\314F\310\300\332\301\314FF\257\6\302\303\304\305\306\307\300\333\301\315F\310\300\334\301\315FF\257\6\302\303\304\305\306\307\300\311\301\316F\310\300\312\301\316FF\257\6\302\303\304\305\306\307\300\317\301\320F\310\300\311\301\320FF\257\6\302\303\304\305\306\307\300\317\301\321F\310\300\311\301\321FF\257\6\302\303\304\305\306\307\300\335\301\322F\310\300\336\301\322FF\257\6&\6\337\340\341\342\343FF!D\257\6\207" [:character :line :annotationId "default" :newText "arr" :range :end :start 71 68 vector 87 88 89 74 90 91 93 :id :jsonrpc "2.0" :result :documentChanges :edits 11 8 32 29 50 47 :textDocument :uri "file:///home/joost/Projects/Python/pyscratch/src/search.py" :version nil] 34]
> > > > ```
> > > >
> > > > Looks like basedpyright is reporting that it didn't make any changes in the
> > > > first case (':results nil').
> > > >
> > > > 2. Emacs did not signal an error.
> > > >
> > > > 3. The language server I used is basedpyright, which can be installed from
> > > > PyPI with the usual tools. I have version 1.17.5, which is the latest
> > > > release.
> > > >
> > > > To configure Eglot to use it, the basedpyright docs suggest to add the
> > > > following to one's init file (which is what I do):
> > > >
> > > > ```
> > > > (add-to-list 'eglot-server-programs
> > > >              '((python-mode python-ts-mode)
> > > >                "basedpyright-langserver" "--stdio"))
> > > > ```
> > > >
> > > > See https://docs.basedpyright.com/#/installation for details.
> > > >
> > > > 4. For a minimal project, all you'll need is a single Python file with a
> > > > single function, which can be as simple as this:
> > > >
> > > > ```
> > > > def some_func():
> > > >     a: int = 5
> > > >     b: int = d + 7
> > > >     c: int = d + 13
> > > >     print(b+c)
> > > > ```
> > > >
> > > > Try to rename the two occurrences of 'd' to 'a'.
> > > >
> > > > The code snippet in my original email will also do, even if basedpyright
> > > > will report a bunch of errors in it for undefined functions. Those don't
> > > > affect the rename.
> > > >
> > > > 5. Emacs: 29.4, Eglot 1.17 (from GNU ELPA), basedpyright 1.17.5.
> > > >
> > > > 6. I assume the issue is so straightforward that there's no need for a
> > > > recipe that's more detailed than the above.
> > > >
> > > > Thanks,
> > > >
> > > > Joost
> > > >
> > > >
> > > > --
> > > > Joost Kremers
> > > > Life has its moments
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >