elbywan / crystalline

A Language Server Protocol implementation for Crystal. 🔮
MIT License
424 stars 21 forks source link

Formatter runs forever #20

Open baelter opened 3 years ago

baelter commented 3 years ago

When I enable this in vscode with format on save enabled the formatter runs forever with 100% cpu. Formatting is working fine without the language server, so could you add an option to disable it in the language server?

code --version
1.52.1
ea3859d4ba2f3e577a159bc91e3074c5d85c0523
x64

macos 11.1

crystalline 0.2
elbywan commented 3 years ago

Hi @baelter,

Formatting is working fine without the language server, so could you add an option to disable it in the language server

The easiest way would be to add a config. option but it would need to be handled by the editor plugin I think. I could also add a specific cli flag to turn it off but I would rather fix the issue if possible 😉.

When I enable this in vscode with format on save enabled the formatter runs forever with 100% cpu.

I have a hard time reproducing this issue on my computer. Out of curiosity, does crystal tool format output an error or take a long time to run? If possible, could you also look at the crystalline logs and check if there is something unusual there? (cmd+shift+P > type "logs" and pick "Developer: Show Logs…" > select any source > choose "Crystal Language" in the logs dropdown)

elbywan commented 3 years ago

I just released 📦 v0.2.1 that might fix the issue, could you try upgrading your crystalline version?

baelter commented 3 years ago

Sweet, will do. Just have to reproduce and check those logs first!

baelter commented 3 years ago

Getting some error output which does not make sense:

[Warn  - 8:51:11 AM] In src/client/client.cr:317:43

 317 | close_connection(frame, 504_u16, "CHANNEL_ERROR - Channel #{frame.channel} not open")
                                         ^
Error: unexpected token: CHANNEL_ERROR
[Warn  - 8:51:49 AM] In src/client/client.cr:316:74

 316 | @log.error { "Channel #{frame.channel} not open when handling #{frame.class.name}" }
                                                                        ^
Error: unexpected token: }

There are no issues with the code.

crystal tool format src/client/client.cr does not error.

Same with v0.2.1.

Not sure if it's related to the hanging formatting, that seems kinda random.

baelter commented 3 years ago
Screenshot 2021-02-02 at 09 11 12

This can take up to a minute. No output in the logs. Running latest version now.

elbywan commented 3 years ago

This can take up to a minute. No output in the logs. Running latest version now.

This is weird, saving should only call the built-in crystal formatter (same as crystal tool format).

Unfortunately a bug in the Crystal compiler prevents me from compiling and running crystalline since the last release (0.36.1). I'm waiting for the Crystal team to fix this before I'll be able to investigate more. (see https://github.com/crystal-lang/crystal/issues/10359)