From 7910dadbca869512b869c927be3c56b9127a2847 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 22 Jan 2021 09:51:32 +0100 Subject: [PATCH] LanguageClient: Do not filter executed commands The commands provided with the capabilities are not the only allowed commands, but the ones that can always be executed. Change-Id: Ie005fafe2e64c334f67809c00623dec2901972c6 Reviewed-by: Christian Stenger --- src/plugins/languageclient/client.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index 79108970594..f3f76b87643 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -708,23 +708,13 @@ void Client::handleCodeActionResponse(const CodeActionRequest::Response &respons void Client::executeCommand(const Command &command) { - using CommandOptions = LanguageServerProtocol::ServerCapabilities::ExecuteCommandOptions; const QString method(ExecuteCommandRequest::methodName); - if (Utils::optional registered = m_dynamicCapabilities.isRegistered(method)) { - if (!registered.value()) - return; - const CommandOptions option(m_dynamicCapabilities.option(method).toObject()); - if (option.isValid(nullptr) && !option.commands().isEmpty() && !option.commands().contains(command.command())) - return; - } else if (Utils::optional option = m_serverCapabilities.executeCommandProvider()) { - if (option->isValid(nullptr) && !option->commands().isEmpty() && !option->commands().contains(command.command())) - return; - } else { - return; - } - - const ExecuteCommandRequest request((ExecuteCommandParams(command))); - sendContent(request); + bool serverSupportsExecuteCommand = m_serverCapabilities.executeCommandProvider().has_value(); + serverSupportsExecuteCommand = m_dynamicCapabilities + .isRegistered(ExecuteCommandRequest::methodName) + .value_or(serverSupportsExecuteCommand); + if (serverSupportsExecuteCommand) + sendContent(ExecuteCommandRequest(ExecuteCommandParams(command))); } static const FormattingOptions formattingOptions(const TextEditor::TabSettings &settings)