castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
423 stars 25 forks source link

Feature request: Listen to available server instead of hard-crashing #197

Open Fire- opened 3 years ago

Fire- commented 3 years ago

Hey there,

I run the solargraph server in a docker container with forwarded ports. While this works pretty well, it unfortunately requires a bit of a dance with regard to the extension, as even in external mode, the extension expects the server to be immediately available the instant the extension starts, and if that fails, it takes focus to its spammy ~five failures in the Output tab, and then never retries; In fact, the extension itself is soft-locked at this point, and cannot be restarted without restarting the entire extension host.
I presume this is because "restart solargraph" requires the extension to tell the server to restart first, and if there is no server, it doesn't know what to do.

As restarting my development environment ( which includes my devtools like solargraph ) is a pretty common occurrence, my current workflow is to

  1. restart the solargraph server,
  2. wait for it to come up,
  3. manually restart the entire vscode extension host.
  4. wait for the solargraph extension to connect to the host
  5. do some work
  6. restart the solargraph container
  7. get focus-pulled to the vscode Output tab by vscode-solargraph
  8. go to 2
  9. Rinse and repeat

It would be nice if, instead of crashing out,

  1. the extension could enter a "waiting" state when using an external server as the host, and unable to connect.
  2. when the extension host connection is lost, note connection loss and awaiting reconnection in the status bar, and re-enter the waiting state until connection is re-established.

These would provide a better experience for the external server rather than forcing focus on the connection failures it's printing to the Output tab, as it currently does

helloguille commented 2 years ago

This is exactly my problem. I had to restart the extension host for it to work.

The problem is that I have my docker-compose running inside my VS Code tasks, so when I open my workspace, the extension fails before solar-graph becomes available via Docker.

helloguille commented 2 years ago

With some guidance from the maintainers, I could make the change myself and submit a pull-request.