Skip to content

Commit

Permalink
[flow] Stop including source as supported code actions
Browse files Browse the repository at this point in the history
Summary:
We shouldn't advertise that we support arbitrary `"source"` because we don't. Doing it will just cause vscode to send us irrelevant ones (e.g. those from eslint). The problem will be especially bad for code-actions on save, because save will be blocked by code actions, and during save we might do expensive dependency analysis that blocks our ability to even respond to code-actions that should be ignored.

Changelog: [misc] Flow language server will stop advertising that we can handle all code actions kinds prefixed with `"source"`. It can help to prevent VSCode sending flow irrelevant code actions to handle during save.

Reviewed By: panagosg7

Differential Revision: D67536771

fbshipit-source-id: 33e4835a5e6c068cbdce6132bac543c85b08df15
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Dec 20, 2024
1 parent a848ca1 commit d545d7d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion newtests/lsp/code-action/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = (suite(
[
[
'initialize',
'{"codeActionProvider":{"codeActionKinds":["source","source.addMissingImports.flow","source.organizeImports.flow","refactor.extract","quickfix"]}}',
'{"codeActionProvider":{"codeActionKinds":["source.addMissingImports.flow","source.organizeImports.flow","refactor.extract","quickfix"]}}',
],
],
[...lspIgnoreStatusAndCancellation],
Expand Down
3 changes: 1 addition & 2 deletions src/lsp/flowLsp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,7 @@ let do_initialize params : Initialize.result =
in
let supported_code_action_kinds =
if supports_source_actions then
CodeActionKind.source
:: CodeActionKind.kind_of_string "source.addMissingImports.flow"
CodeActionKind.kind_of_string "source.addMissingImports.flow"
:: CodeActionKind.kind_of_string "source.organizeImports.flow"
:: supported_code_action_kinds
else
Expand Down

0 comments on commit d545d7d

Please sign in to comment.