sublimelsp / LSP-volar

Vue support for Sublime's LSP plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code actions are spotty on Windows

Bocom opened this issue · comments

System info
Windows 11 Pro 21H2
Sublime Text 4 (4131)
Node 16.13.2 (through Volta, but LSP's local runtime doesn't work either)
LSP 1.16.2
LSP-volar 1.0.18

Issue
Previously I had problems getting Volar to run properly on Windows, and while that was fixed I was still having some issues, but had moved on to other (non-Vue) projects so I didn't have the time or energy to look into it at the time. Now that I've been working on a Vue project again, these issues crept up again, so I'm making a new issue about one of them in particular.

Basically, Volar (or the TypeScript server, not entirely sure) is reporting on every line inside a Vue script tag (even empty lines) that there are at least 13 code actions available (often more depending on what the cursor is sitting on), but most of them are not logical for the context and will either crash Volar when selected or silently do nothing, mostly the former.

However, sometimes accurate code actions don't execute like they should, for example importing things through a code action might sometimes just not go do anything, but other times it adds the import just fine. It's hard to reproduce, so it's not included in the logs.

This doesn't happen in Visual Studio Code, and as far as I know, Code and Sublime LSP are using the same underlying dependencies (i.e. my project's TypeScript v4.7.3).

Logs
Here is the system log:
system.log

And here is the language server log:
languageserver.log

So, I decided to check my WSL2 install of ST and it turns out it happens there too? Which made me go and install LSP-volar on a MacBook Pro that I'm current borrowing and it turns out that it happens there too! 👀

Maybe specific to the project you are using it on then? If you'd provide that then someone might check it out.

The logs I posted are from a project I created with pnpm create vite (vue-ts preset) to confirm whether it's just my project or not, and it's not just my project that's making this happen.

I went and checked what this looks like in coc-volar (Vim, as to see if this is just a thing outside of VS Code) and saw that it lists the same code actions, but most of them are disabled. After adding some extra logging to LSP's code actions handler, I saw that they are indeed sent as disabled, with the reason why they are disabled as well.

So I guess that particular issue is a quirk in how LSP are presenting code actions, i.e. it's not filtering out (or marking them) disabled actions, but it doesn't solve the issue of Volar crashing on legitimate code actions (like highlighting a block of code and picking "Extract function"), but it seems like it might not be a LSP-volar specific issue... 😕

One thing at a time. I'm implementing support for "disabled" code actions in sublimelsp/LSP#1975 by filtering them out.

BTW. A proper-behaving server would not use "disabled" property on code actions if the client doesn't explicitly announce support for them. I would expect the server to filter them out itself instead.

@johnsoncodehk, FYI