Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions crates/ruff_server/src/server/api/requests/execute_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,24 @@ 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<Option<serde_json::Value>> {
let command = SupportedCommand::from_str(&params.command)
.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::notification::LogMessage>(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
Expand Down
Loading