pantajoe / vscode-elixir-credo

VSCode support for Elixir Linter 'Credo'.

Home Page:https://marketplace.visualstudio.com/items?itemName=pantajoe.vscode-elixir-credo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extension errors when CMD/CTRL+hovering symbols from other files

jaminthorns opened this issue · comments

When holding CMD/CTRL and hovering a module or function from another file, it seems like Credo tries to run on that file but fails, causing this error message to be displayed as a notification:

Command /Users/jamin/.asdf/shims/mix credo returns empty output! Please check your configuration. Did you add or modify your dependencies? You might need to run mix deps.get or recompile.

The error only occurs when the file of the hovered symbols is not open:

Screen.Recording.2021-11-30.at.11.12.30.AM.mov

The error does not occur when the file is already open:

Screen.Recording.2021-11-30.at.11.12.50.AM.mov

This is the debug log (elixir.credo.enableDebug set to true) when duplicating the error:

> Retreiving credo information: Executing credo command `/Users/jamin/.asdf/shims/mix credo info --format json --verbose` for /Users/jamin/Projects/vscode_elixir_issue/lib/other_module.ex in directory /Users/jamin/Projects/vscode_elixir_issue

> Removing linter messages and cancel running linting processes for /Users/jamin/Projects/vscode_elixir_issue/lib/other_module.ex.

> Command `/Users/jamin/.asdf/shims/mix credo` returns empty output! Please check your configuration. Did you add or modify your dependencies? You might need to run `mix deps.get` or recompile.

The extension still functions correctly (linting open Elixir files), though.

Steps to Reproduce

  1. Create a new Elixir project with mix new.
  2. Install Credo and set up config with mix credo.gen.config.
  3. Create a new file and module (OtherModule) with a function (some_function).
  4. Reference that function in another file and module (MainModule).
  5. Close all files except the one containing MainModule.
  6. Hold CMD/CTRL and hover over OtherModule or some_function.
  7. Observe the "returns empty output" error in a notification.

Hello there! Thanks for bringing that up. That seems to happen because of microsoft/vscode#109908: When the hover popup is opened it triggers the event that a document has open, and, thus, the document starts a linting process. However, immediately afterwards, vscode triggers the event that the document has been closed. This in turn triggers all running credo processes for this document to be cancelled.

I'll release a fix where SIGTERM errors on credo processes will not be reported.