unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#73414: eglot: using auto-revert-mode and git checkout corrupts diagnostics
@ 2024-09-21 19:13 Romain Ouabdelkader
  2024-09-26 15:06 ` bug#73414: eglot: using auto-revert-mode and git checkout corrupts diagn Romain Ouabdelkader
  0 siblings, 1 reply; 4+ messages in thread
From: Romain Ouabdelkader @ 2024-09-21 19:13 UTC (permalink / raw)
  To: 73414


[-- Attachment #1.1: Type: text/plain, Size: 1333 bytes --]

Hello,

With auto-revert-mode and eglot enabled, using a git checkout to change
branch will leave invalid buffer diagnostics.

Emacs version: GNU Emacs 30.0.91
Operating system: Mac OS X
Eglot version: reproduced with emacs -Q on emacs30 pretest.
Server used: pyright

Steps to reproduce:

Using the following file:

```
def print_lorem_ipsum():
    print("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")

def print_lorem_ipsum_upper():
    print("LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT.")
```

1. Initialize the git repository:

$ git init
$ git add a.py
$ git commit

$ git checkout -b test
# edit a.py and remove the function print_lorem_ipsum_upper
$ git add a.py
$ git commit

2. Start emacs on the test branch:

$ emacs -Q a.py
M-x auto-revert-mode
M-x eglot

3. Then go to the main branch:

$ git checkout main

After auto-revert-mode triggers a file reload, eglot will report that the
function print_lorem_ipsum_upper is duplicated. (See screenshot in
attachment)
See also the `eglot-events-buffer` logs in attachment.

In this state, even if you delete the function and rewrite it, the error
will stay.
The only way to fix the issue is to do a eglot-reconnect.

I can reproduce the issue on emacs30 with built-in eglot and I didn't have
the problem on emacs29 with eglot 1.15 from ELPA.

Thanks.

[-- Attachment #1.2: Type: text/html, Size: 1589 bytes --]

[-- Attachment #2: eglot_logs.txt --]
[-- Type: text/plain, Size: 9954 bytes --]

[jsonrpc] D[14:15:45.236] Running language server: /Users/redacted/.local/bin/pyright-langserver --stdio
[jsonrpc] e[14:15:45.236] --> initialize[1] {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"processId":34187,"clientInfo":{"name":"Eglot","version":"1.17.30"},"rootPath":"/tmp/eglot_bug3/","rootUri":"file:///private/tmp/eglot_bug3","initializationOptions":{},"capabilities":{"workspace":{"applyEdit":true,"executeCommand":{"dynamicRegistration":false},"workspaceEdit":{"documentChanges":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":false},"configuration":true,"workspaceFolders":true},"textDocument":{"synchronization":{"dynamicRegistration":false,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":false,"completionItem":{"snippetSupport":false,"deprecatedSupport":true,"resolveSupport":{"properties":["documentation","details","additionalTextEdits"]},"tagSupport":{"valueSet":[1]}},"contextSupport":true},"hover":{"dynamicRegistration":false,"contentFormat":["plaintext"]},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true},"documentationFormat":["plaintext"],"activeParameterSupport":true}},"references":{"dynamicRegistration":false},"definition":{"dynamicRegistration":false,"linkSupport":true},"declaration":{"dynamicRegistration":false,"linkSupport":true},"implementation":{"dynamicRegistration":false,"linkSupport":true},"typeDefinition":{"dynamicRegistration":false,"linkSupport":true},"documentSymbol":{"dynamicRegistration":false,"hierarchicalDocumentSymbolSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"documentHighlight":{"dynamicRegistration":false},"codeAction":{"dynamicRegistration":false,"resolveSupport":{"properties":["edit","command"]},"dataSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"isPreferredSupport":true},"formatting":{"dynamicRegistration":false},"rangeFormatting":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false},"inlayHint":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":false,"codeDescriptionSupport":false,"tagSupport":{"valueSet":[1,2]}}},"window":{"showDocument":{"support":true},"workDoneProgress":true},"general":{"positionEncodings":["utf-32","utf-8","utf-16"]},"experimental":{}},"workspaceFolders":[{"uri":"file:///private/tmp/eglot_bug3","name":"/tmp/eglot_bug3/"}]}}
[jsonrpc] e[14:15:45.376] <-- window/logMessage {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Pyright language server 1.1.365 starting"}}
[jsonrpc] e[14:15:45.376] <-- window/logMessage {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Server root directory: file:///Users/redacted/.cache/pyright-python/1.1.365/node_modules/pyright/dist"}}
[jsonrpc] e[14:15:45.378] <-- window/logMessage {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Starting service instance \"/tmp/eglot_bug3/\""}}
[jsonrpc] e[14:15:45.403] <-- initialize[1] {"jsonrpc":"2.0","id":1,"result":{"capabilities":{"textDocumentSync":2,"definitionProvider":{"workDoneProgress":true},"declarationProvider":{"workDoneProgress":true},"typeDefinitionProvider":{"workDoneProgress":true},"referencesProvider":{"workDoneProgress":true},"documentSymbolProvider":{"workDoneProgress":true},"workspaceSymbolProvider":{"workDoneProgress":true},"hoverProvider":{"workDoneProgress":true},"documentHighlightProvider":{"workDoneProgress":true},"renameProvider":{"prepareProvider":true,"workDoneProgress":true},"completionProvider":{"triggerCharacters":[".","[","\"","'"],"resolveProvider":true,"workDoneProgress":true,"completionItem":{"labelDetailsSupport":true}},"signatureHelpProvider":{"triggerCharacters":["(",",",")"],"workDoneProgress":true},"codeActionProvider":{"codeActionKinds":["quickfix","source.organizeImports"],"workDoneProgress":true},"executeCommandProvider":{"commands":[],"workDoneProgress":true},"callHierarchyProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}}}}}
[jsonrpc] e[14:15:45.403] --> initialized {"jsonrpc":"2.0","method":"initialized","params":{}}
[jsonrpc] e[14:15:45.403] --> textDocument/didOpen {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///private/tmp/eglot_bug3/a.py","version":0,"languageId":"python","text":"def print_lorem_ipsum():\n    print(\"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\")\n"}}}
[jsonrpc] e[14:15:45.404] --> workspace/didChangeConfiguration {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}
[jsonrpc] e[14:15:45.425] <-- client/registerCapability[0] {"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"4ccfa5aa-9db3-4e25-bc43-e2c0f6456c6a","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/pyrightconfig.json","kind":7},{"globPattern":"**","kind":7}]}}]}}
[jsonrpc] e[14:15:45.432] --> client/registerCapability[0] {"jsonrpc":"2.0","id":0,"result":null}
[jsonrpc] e[14:15:45.432] <-- workspace/configuration[1] {"jsonrpc":"2.0","id":1,"method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///private/tmp/eglot_bug3","section":"python"}]}}
[jsonrpc] e[14:15:45.433] --> workspace/configuration[1] {"jsonrpc":"2.0","id":1,"result":[null]}
[jsonrpc] e[14:15:45.438] <-- workspace/configuration[2] {"jsonrpc":"2.0","id":2,"method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///private/tmp/eglot_bug3","section":"python.analysis"}]}}
[jsonrpc] e[14:15:45.438] --> workspace/configuration[2] {"jsonrpc":"2.0","id":2,"result":[null]}
[jsonrpc] e[14:15:45.439] <-- workspace/configuration[3] {"jsonrpc":"2.0","id":3,"method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///private/tmp/eglot_bug3","section":"pyright"}]}}
[jsonrpc] e[14:15:45.439] --> workspace/configuration[3] {"jsonrpc":"2.0","id":3,"result":[null]}
[jsonrpc] e[14:15:45.483] <-- window/logMessage {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Found 1 source file"}}
[jsonrpc] e[14:15:45.483] <-- client/registerCapability[4] {"jsonrpc":"2.0","id":4,"method":"client/registerCapability","params":{"registrations":[{"id":"730fd6e7-b42b-4491-83f3-26f37d239bbb","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/pyrightconfig.json","kind":7},{"globPattern":"**","kind":7}]}}]}}
[jsonrpc] e[14:15:45.490] --> client/registerCapability[4] {"jsonrpc":"2.0","id":4,"result":null}
[jsonrpc] e[14:15:45.491] <-- client/unregisterCapability[5] {"jsonrpc":"2.0","id":5,"method":"client/unregisterCapability","params":{"unregisterations":[{"id":"4ccfa5aa-9db3-4e25-bc43-e2c0f6456c6a","method":"workspace/didChangeWatchedFiles"}]}}
[jsonrpc] e[14:15:45.491] --> client/unregisterCapability[5] {"jsonrpc":"2.0","id":5,"result":null}
[jsonrpc] e[14:15:45.751] <-- textDocument/publishDiagnostics {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///private/tmp/eglot_bug3/a.py","version":0,"diagnostics":[]}}
[jsonrpc] e[14:15:57.812] --> workspace/didChangeWatchedFiles {"jsonrpc":"2.0","method":"workspace/didChangeWatchedFiles","params":{"changes":[{"uri":"file:///private/tmp/eglot_bug3/.git","type":2}]}}
[jsonrpc] e[14:15:57.812] --> workspace/didChangeWatchedFiles {"jsonrpc":"2.0","method":"workspace/didChangeWatchedFiles","params":{"changes":[{"uri":"file:///private/tmp/eglot_bug3/a.py","type":2}]}}
[jsonrpc] e[14:15:58.031] --> textDocument/didClose {"jsonrpc":"2.0","method":"textDocument/didClose","params":{"textDocument":{"uri":"file:///private/tmp/eglot_bug3/a.py"}}}
[jsonrpc] e[14:15:58.031] --> textDocument/didOpen {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///private/tmp/eglot_bug3/a.py","version":0,"languageId":"python","text":"def print_lorem_ipsum():\n    print(\"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\")\n\n\ndef print_lorem_ipsum_upper():\n    print(\"LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT.\")\n"}}}
[jsonrpc] e[14:15:58.090] --> textDocument/didChange {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///private/tmp/eglot_bug3/a.py","version":1},"contentChanges":[{"range":{"start":{"line":2,"character":0},"end":{"line":2,"character":0}},"rangeLength":0,"text":"\n\ndef print_lorem_ipsum_upper():\n    print(\"LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT.\")\n"}]}}
[jsonrpc] e[14:15:58.092] <-- textDocument/publishDiagnostics {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///private/tmp/eglot_bug3/a.py","diagnostics":[]}}
[jsonrpc] e[14:15:58.092] <-- textDocument/publishDiagnostics {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///private/tmp/eglot_bug3/a.py","version":0,"diagnostics":[]}}
[jsonrpc] e[14:15:58.357] <-- textDocument/publishDiagnostics {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///private/tmp/eglot_bug3/a.py","version":1,"diagnostics":[{"range":{"start":{"line":4,"character":4},"end":{"line":4,"character":27}},"message":"Function declaration \"print_lorem_ipsum_upper\" is obscured by a declaration of the same name","severity":1,"code":"reportRedeclaration","source":"Pyright","codeDescription":{"href":"https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportRedeclaration"},"relatedInformation":[{"location":{"uri":"file:///private/tmp/eglot_bug3/a.py","range":{"start":{"line":8,"character":4},"end":{"line":8,"character":27}}},"message":"See function declaration"}]}]}}

[-- Attachment #3: Screenshot 2024-09-21 at 14.30.02.png --]
[-- Type: image/png, Size: 126384 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-09-26 21:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-21 19:13 bug#73414: eglot: using auto-revert-mode and git checkout corrupts diagnostics Romain Ouabdelkader
2024-09-26 15:06 ` bug#73414: eglot: using auto-revert-mode and git checkout corrupts diagn Romain Ouabdelkader
2024-09-26 15:44   ` Eli Zaretskii
2024-09-26 21:29     ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).