lsp

pez 2025-03-18T18:20:38.468759Z

We have a serious issue possibly incoming for Calva users. With VS Code Insiders Version: 1.99.0-insider (regular VS Code is currently on 1.98) this code freezes the current editor tab:

#_(
)
Or any ignored form that goes over more than one line. With clojure-lsp stopped the file works fine. Starting clojure-lsp instantly freezes the file. The freeze is not complete, however. You can’t move the cursor. And scrolling often blanks out the text in the file. But some commands work. Like, I can delete and undo. So I can reproduce this by having this (`|` is the cursor):
|(
)
And then enter #_ :
#_|(
)
Now I can’t move the cursor, but I can delete the _ :
#|(
)
And now I can move the cursor again. I haven’t searched the VS Code issues for this yet, but I will do so now and report back with what I (probably won’t) find. Let me know what more I can do to gather information. Yeah, just asking that I realize I should provide a message log. Will attach in 🧵 . cc: @ingy (the canary).

pez 2025-03-19T08:34:13.948469Z

@ericdallo a problem with filtering these token out is that now Calva depends on an internal detail of clojure-lsp, iiuc. That comment tokens are indexed with 10. Would you consider a PR that included the token vector with server-info? Then Calva can use that for its filtering decisions.

ericdallo 2025-03-19T12:19:41.106689Z

yeah, that's dangerous, I think it makes sense, feel free to create a issue or a PR for that

👍 2
pez 2025-03-19T21:39:29.772809Z

The issue is hitting other extensions too. Or at least vscode-go: https://github.com/golang/vscode-go/issues/3724

Ingy döt Net 2025-03-19T21:40:39.713559Z

Should garner more attention 🙂

😂 1
ericdallo 2025-03-18T18:22:34.752089Z

Interesting, looks like a vscode semantic token coloring issue, I can't repro on Emacs or Intellij (using clojure-lsp)

ericdallo 2025-03-18T18:22:50.743839Z

Would be nice to double check if disabling semantic tokens the problem is solved but I'd not suggest that as a final fix

pez 2025-03-18T18:23:05.825309Z

I’ll try that now.

Ingy döt Net 2025-03-18T18:23:06.930999Z

it's only in the latest vscode-insiders with calva on

pez 2025-03-18T18:26:27.159029Z

With semantic tokens off the problem goes away.

ericdallo 2025-03-18T18:26:47.956149Z

yeah, it's definitely a vscode issue

pez 2025-03-18T18:29:15.976349Z

So should be reproducible somehow in some other language. We just need to figure out how…

pez 2025-03-18T18:30:13.021019Z

Is there some token you add for ignored forms, @ericdallo?

Ingy döt Net 2025-03-18T18:30:56.017369Z

> With semantic tokens off the problem goes away. can you tell me how so I can avoid this for the time being?

pez 2025-03-18T18:31:27.162979Z

Put this is .lsp/config.edn

{:semantic-tokens? false}

✅ 1
ericdallo 2025-03-18T18:31:34.496309Z

yes, latest clojure-lsp added new tokens for comment forms

Ingy döt Net 2025-03-18T18:35:27.858789Z

@pez works for me too fyi. cheers.

🙏 1
pez 2025-03-18T18:39:21.994249Z

I see this. But I can’t repro in TypeScript that easily.

pez 2025-03-18T18:47:37.909289Z

So, it’s with latest clojure-lsp and VS Code 1.99-insiders. Using the previous version of clojure-lsp 2025.02.07-16.11.24 also dodges this bullet.

ericdallo 2025-03-18T18:50:19.655479Z

yeah, but I think as soon vscode releases this we will have a big problem in Calva

💯 1
ericdallo 2025-03-18T18:50:39.030309Z

would be best to report this issue in vscode

ericdallo 2025-03-18T18:51:02.789229Z

also disabling semantic tokens is pretty bad

Ingy döt Net 2025-03-18T18:52:19.302049Z

Is there a fix that can happen on the clojure side for a specific version of vscode if they don't fix in time?

ericdallo 2025-03-18T18:53:18.674749Z

no, disabling semantic tokens is the only way as clojure-lsp is correct

Ingy döt Net 2025-03-18T18:54:01.372629Z

I mean auto disable it if using a bad version of vscode

ericdallo 2025-03-18T18:54:22.706799Z

hum, not easy to do I think

Ingy döt Net 2025-03-18T18:55:01.777919Z

ok just wanted to throw that idea out there.

Ingy döt Net 2025-03-18T18:55:57.262749Z

which clojurians have the skills to patch vscode and push on a PR? might want to ping them...

ericdallo 2025-03-18T18:59:17.641089Z

good question

pez 2025-03-18T19:18:06.317519Z

Reporting to vscode is the reason I want to repro with TypeScript.

👍 1
pez 2025-03-18T19:18:51.098249Z

Since it is on Insiders we may not need to patch anything if the vscode team is alerted in time in a way they understand.

👍 1
ericdallo 2025-03-18T19:18:59.161049Z

makes sense

pez 2025-03-19T00:21:20.218949Z

https://github.com/microsoft/vscode/issues/243923

👍 2
pez 2025-03-19T00:23:39.335449Z

I think a big part of the issue is that VS Code does not support multiline tokens. As we can see also with the current stable version of VS Code.

ericdallo 2025-03-19T00:44:02.308539Z

Ah I doubt, they created the semantic tokens using vscode as primary case, the LSP spec always use vscode for those things, and multiline tokens are kind of obvious to support

pez 2025-03-19T01:47:36.393049Z

Here’s a version of Calva that filters comment tokens from the semantic tokens provided by clojure-lsp. • https://output.circle-artifacts.com/output/job/90e3fe44-95b8-4394-bd7a-d024d90941e5/artifacts/0/tmp/artifacts/calva-2.0.492-2757-filter-comment-tokens-e5b7e2ea.vsix It then avoids the bug in VS Code and keeps working in files with ignored lists. It also avoids the disabling of syntax highlighting that these tokens cause. Can you give it a spin, @ingy? With semantic tokens enabled again. Related PR and issue: • https://github.com/BetterThanTomorrow/calva/pull/2758https://github.com/BetterThanTomorrow/calva/issues/2757

Ingy döt Net 2025-03-19T01:58:29.533359Z

@pez I can try it. What's the best way to install that?

Ingy döt Net 2025-03-19T02:00:47.636909Z

https://stackoverflow.com/questions/42017617/how-to-install-vs-code-extension-manually Something like that?

Ingy döt Net 2025-03-19T03:39:37.958659Z

@pez I did intstall it and then removed the .lsp/config.edn that we used as a workaround. It does seem to work now.

Ingy döt Net 2025-03-19T03:41:11.240959Z

I have to mention that it froze again. It froze after I deleted the #_ form that first brought it to our attention! Then I undid the delete and it worked again. And I can't get it to freeze again, but weird right?

pez 2025-03-19T06:28:44.642599Z

Thanks for testing! 🙏 Super weird with that revisit of the freeze. We’re up against undefined behavior, obviously. I’ll run with this build too and we’ll see what gives.

pez 2025-03-22T11:08:08.398949Z

The pressure is building: • Dart: https://github.com/microsoft/vscode/issues/244266 • And also Lua: https://github.com/microsoft/vscode/issues/243923#issuecomment-2743249274

🙌 2
Ingy döt Net 2025-03-22T14:19:16.079319Z

https://github.com/microsoft/vscode/issues/243923#issuecomment-2745290050 just in

pez 2025-03-22T14:20:49.683599Z

So it’s definitely about multiline tokens.

Ingy döt Net 2025-03-22T14:22:59.214589Z

I tried heredocs in perl and bash and they were ok

Ingy döt Net 2025-03-22T14:23:23.473969Z

also tried

/*
...
*/
in java

Ingy döt Net 2025-03-22T14:39:01.850549Z

Ah I guess its triggered by certain extensions...

Ingy döt Net 2025-03-22T14:39:07.008609Z

nvm

pez 2025-03-22T15:01:50.184309Z

It depends how the token is highlighted. For many languages there is TextMate grammar doing it. It can also be done with a semantic tokens provider. That’s when it hits this bug. It can also be done by just coloring the text in the buffer. Like Calva does for ignore tokens.

pez 2025-03-22T15:03:09.573409Z

I tried with tagged literals in TypeScript and it didn’t produce semantic tokens for it, so guessing it’s TM grammar in action.

pez 2025-03-22T15:04:22.874919Z

There’s a command in VSCode for inspecting tokens that will show you the TM and semantic tokens for things.

pez 2025-03-18T22:13:48.690539Z

The comment semantic tokens for ignored forms are not awesome together with Calva even without the freeze. They remove the syntax highlighting of ignored forms. And only on the first line, which gets extra weird, (but the fix is not to make it remove it on all lines, I would say).

ericdallo 2025-03-18T22:21:57.597569Z

That looks like a bug in vscode as well, @andreribeirocamargo can you take a look please?

pez 2025-03-18T22:25:37.890659Z

Which looks like a bug?

ericdallo 2025-03-18T22:35:31.855649Z

The one coloring only the first line

pez 2025-03-18T22:38:49.344639Z

I was afraid you would say that. 😃

ericdallo 2025-03-18T22:39:56.956789Z

The best is to debug semantic tokens request and confirm clojure-lsp is returning proper tokens range, but it's a vector of integers so it might be hard to understand

pez 2025-03-18T22:44:05.504889Z

All I have figured out so far is that index 3 is the token type and that type 10 is comment tokens.

pez 2025-03-18T22:46:22.763149Z

I will filter out these tokens in the lsp client. It will fix the issue with removal of syntax highlighting and also stops Insiders from croaking.

ericdallo 2025-03-18T22:48:04.203649Z

Every 5 integers means a token, first is the line from last token, second the column, third the length of the token to color from the start, fourth is the token type and 5 the token modifiers list as bitwise, but that's irrelevant here

ericdallo 2025-03-18T22:48:39.667389Z

Ok, but would be nice to fix the root cause later

pez 2025-03-18T22:49:50.242789Z

I’ll try to figure out a way to report the Insiders issue. But I understand a bit too little about the problem so may not do a very good job.