castwide / vscode-solargraph

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

Solargraph gets stuck when saving file #234

Open ruggieroguida opened 2 years ago

ruggieroguida commented 2 years ago
OS: Bigsur
vscode version: 1.62.2
Ruby 2.7.1 (with rbenv)
solargraph version: 0.44.0
extension version: v0.23.0

All of a sudden solargraph has stopped working. It is not allowing me to save any file and it gets stuck at

"Saving 'anyfile.rb': Running 'Ruby Solargraph' Formatter (configure)."

The only way to proceed is to click cancel. I literally cannot save any file. It has been working fine for years.

This is the content of .solargraph.yml. No change from the default one

---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- vendor/**/*
- ".bundle/**/*"
require: []
domains: []
reporters:
- rubocop
- require_not_found
formatter:
  rubocop:
    cops: safe
    except: []
    only: []
    extra_args: []
require_paths: []
plugins: []
max_files: 5000

Any suggestion?

castwide commented 2 years ago

What are your editor.formatOnSave and editor.formatOnSaveMode options?

If you use format on save for other languages, you can disable it for Ruby only in settings.json, e.g.:

    "[ruby]": {
        "editor.formatOnSave": false
    }

I'll still see if I can reproduce the error and make it work correctly. Do you get an error message and/or backtrace in the debug console (Help -> Toggle Developer Tools)?

ruggieroguida commented 2 years ago

I deleted the project folder and started again and it worked fine.

I managed to reproduce it though.

My new, working settings.json (workspace) has only one line

{
  "solargraph.formatting": true
}

If I add "editor.formatOnSave": true it happens again.

The only message from the console is

[Extension Host] Config changed. Should lint: 1

when I change settings.json

castwide commented 2 years ago

Do you also have the rebornix.Ruby extension installed? I suspect that's what sent the "Should lint: 1" message.

ruggieroguida commented 2 years ago

Nope. I cannot even find it on the marketplace actually

castwide commented 2 years ago

This one: https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby

ruggieroguida commented 2 years ago

Oh :-)

Yes. I do

seanders commented 2 years ago

Related question that I didn't want to create a new issue for: Is the formatter intended to work with this setting?:

editor.formatOnSaveMode: 'modifications'

Setting info here: https://code.visualstudio.com/docs/getstarted/settings#_default-settings

Solargraph formatting works went it formats the whole file. It seems that rubocop doesn't support 'partial' formatting out of the box. (See: https://github.com/rubocop/rubocop/issues/5477)

ChristianClassen commented 2 years ago

OS: Bigsur vscode version: 1.63.2 Ruby 2.7.3 solargraph version: 0.44.3 extension version: v0.23.0

Have the exact same problem with two brand new, identical Ruby on Rails Apps (Rails 7).

Result:

"Saving 'anyfile.rb': Running 'Ruby Solargraph' Formatter (configure)."

// VSCode -  Ruby Settings
    // Extension: Ruby (Peng Lv)
    "ruby.useBundler": true,
    "ruby.useLanguageServer": false,
    "ruby.format": false,
    "[ruby]": {
        // "editor.defaultFormatter": "rebornix.ruby"
        "editor.defaultFormatter": "castwide.solargraph"
    },
    // Extension: Ruby Solargraph
    "solargraph.logLevel": "info",
    "solargraph.diagnostics": true,
    "solargraph.useBundler": true,
    "solargraph.formatting": true,