From b8afc1fb11dac1d0d2924ff6025f02eabe612a9a Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Tue, 11 Mar 2025 10:00:03 +0530 Subject: [PATCH] Server: Remove log notification for `printDebugInformation` command For context, the initial implementation started out by sending a log notification to the client to include this information in the client channel. This is a bit ineffective because it doesn't allow the client to display this information in a more obvious way. In addition to that, it isn't obvious from a users perspective as to where the information is being printed unless they actually open the output channel. The change was to actually return this formatted string that contains the information and let the client handle how it should display this information. For example, in the Ruff VS Code extension we open a split window and show this information which is similar to what rust-analyzer does. The notification request was kept as a precaution in case there are users who are actually utilizing this way. If they exists, it should a minority as it requires the user to actually dive into the code to understand how to hook into this notification. With 0.10, we're removing the old way as it only clobbers the output channel with a long message. --- .../src/server/api/requests/execute_command.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/crates/ruff_server/src/server/api/requests/execute_command.rs b/crates/ruff_server/src/server/api/requests/execute_command.rs index be4801e099296..2888e1c85e165 100644 --- a/crates/ruff_server/src/server/api/requests/execute_command.rs +++ b/crates/ruff_server/src/server/api/requests/execute_command.rs @@ -38,7 +38,7 @@ impl super::RequestHandler for ExecuteCommand { impl super::SyncRequestHandler for ExecuteCommand { fn run( session: &mut Session, - notifier: client::Notifier, + _notifier: client::Notifier, requester: &mut client::Requester, params: types::ExecuteCommandParams, ) -> server::Result> { @@ -46,19 +46,16 @@ impl super::SyncRequestHandler for ExecuteCommand { .with_failure_code(ErrorCode::InvalidParams)?; if command == SupportedCommand::Debug { + // TODO: Currently we only use the first argument i.e., the first document that's + // provided but we could expand this to consider all *open* documents. let argument: DebugCommandArgument = params.arguments.into_iter().next().map_or_else( || Ok(DebugCommandArgument::default()), |value| serde_json::from_value(value).with_failure_code(ErrorCode::InvalidParams), )?; - let output = debug_information(session, argument.text_document) - .with_failure_code(ErrorCode::InternalError)?; - notifier - .notify::(types::LogMessageParams { - message: output.clone(), - typ: types::MessageType::INFO, - }) - .with_failure_code(ErrorCode::InternalError)?; - return Ok(Some(serde_json::Value::String(output))); + return Ok(Some(serde_json::Value::String( + debug_information(session, argument.text_document) + .with_failure_code(ErrorCode::InternalError)?, + ))); } // check if we can apply a workspace edit