From d545d7d6ca0e123d4d70ebad56e89c7dbe749afb Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Fri, 20 Dec 2024 13:26:30 -0800 Subject: [PATCH] [flow] Stop including `source` as supported code actions 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 --- newtests/lsp/code-action/test.js | 2 +- src/lsp/flowLsp.ml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/newtests/lsp/code-action/test.js b/newtests/lsp/code-action/test.js index 3b70e6c5892..0ea38f83e9a 100644 --- a/newtests/lsp/code-action/test.js +++ b/newtests/lsp/code-action/test.js @@ -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], diff --git a/src/lsp/flowLsp.ml b/src/lsp/flowLsp.ml index 6e47507a680..653d8f08004 100644 --- a/src/lsp/flowLsp.ml +++ b/src/lsp/flowLsp.ml @@ -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