-
-
Notifications
You must be signed in to change notification settings - Fork 895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LSP ruff shows outdated syntax errors #4547
Comments
|
@jcs090218 I reverted to a commit before the PR and that fixes the issue. I think the issue is probably with how lsp-mode handles ruff-server or maybe with the server itself. |
I have this problem also. This was introduced in #4543. I get errors from |
@jcs090218, according to @MichaReiser from ruff, the ruff server uses pull diagnostics when available. Maybe that's the cause of these errors? In the PR for this change #4543, I don't see anything about pull diagnostics. Does emacs-lsp support them, is it pulling the new diagnostics ? |
Apparently, yes, maybe partally? 7e342a5 |
Can you try to enable |
@jcs090218 I tried setting the variable it doesn't solve the issue. Here are the IO logs it seems like after the file was saved no request was made for diagnostics so the last server response still seems to be indicating syntaxerrors. |
Thanks for the logs. They're very useful to understand the problem. I scrolled through the logs and the diagnostics do get updated (they change after a
What's difficult for me to say is if those are the expected responses because I don't know changes you made to the document. Can you try a shorter test case. For example: Type: a = and then change it to a = 10 ideally in an existing, but otherwise empty file. This should be the most basic case where the editor transitions from code without syntax error to code with sytnax error to code without syntax error. Could you try setting the |
lsp trace + ruff-lsp-trace.txt Gravacao.de.tela.de.2024-09-18.11-29-55.mp4 |
Another workaround: using the latest version of lsp-mode, use the
|
@MichaReiser I could not reproduce stale diagnostics with the a = 10 example But I was able to do it with
Here are the corresponding traces and logs |
I have to do some debugging. Hopefully I find some time tomorrow. I wonder if our UTF32 support is incorrect because the syntax errors aren't really outdated. They make no sense. Like why is there an indent error? In case anyone knows how to do that in lsp-emacs, could you try changing the encoding to UTF-16 (not the file's encoding but the advertised encoding by the client) |
Maybe this issue is related #2080 ? |
It seems like utf-16 support is buggy (multibyte) which is why emacs tries to use utf-32 or utf-8 if i understand the issue correctly? @MichaReiser does the server not support those, what's the difference between it and ruff-lsp which seems to handle it just fine? |
@MichaReiser I've changed to UTF-16 by forcing it to be the only available option in (defun lsp--client-capabilities (&optional custom-capabilities)
"Return the client capabilities appending CUSTOM-CAPABILITIES."
(append
`((general . ((positionEncodings . ["utf-16"])))
;;; rest of function definition here (though, of course, this is a temporary kludge, not a workaround, as this means I've disabled utf-32 support in for all other servers too ...) |
I'll be running |
Yes, I am and I can confirm that it happens when using emoji in the code ;)
Certainly! The workaround is to make sure that the issue is isolated do utf-32 handling, it's not as a possible solution ;)
Yeah, that's me ... :P But restarting the server usually fixes it in the rare occasions I need to change a line with emoji |
That's great news. So we know what the culprit is.
Definitely. My suggestion wasn't to use this long term. But it's a great finding for narrowing the root cause. Let me setup lsp-mode and try to get this fixed. |
Any recommendations and setups that I could use? I've never used emacs before... |
Okay, I have it almost working. I'm failing to figure out how to set a custom path for the ruff executable |
I have it working. Now lets fix the bug |
Okay, this is a very silly bug. I have a fix up soon |
Considering that this is a ruff bug, I recommend closing the issue here and following astral-sh/ruff-lsp#495 |
Thank you @MichaReiser ! |
You're welcome. Thanks for helping me reproduce the problem. We released a new Ruff version yesterday. Could you give it a try? |
The new version seems to have fixed the issue. Thanks. Closing. |
Thank you for the bug report
lsp-mode
related packages.M-x lsp-start-plain
Bug description
It seems like ruff-lsp has the following variable: astral-sh/ruff-lsp#454 that does not seem to exist in lsp-mode for ruff.
ruff-lsp now shows outdated error messages even on saving
None of these errors exist anymore and they go away on
revert-buffer
which presumably restarts the server.Steps to reproduce
Use ruff-lsp version >=0.0.54
Enable both pyright and ruff-lsp. Type something and save. Old syntax errors still show up from ruff-lsp. They go away after revert-buffer
Expected behavior
ruff-lsp should only show updated/current errors
Which Language Server did you use?
ruff-lsp
OS
Linux
Error callstack
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: