From 73dc8b6f06b49f4728a50e83781c361e9a8b3100 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 2 Jan 2020 01:39:01 +0200 Subject: Another attempt to add multiple edits --- crates/ra_lsp_server/src/main_loop/handlers.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index f2db575ea..ec3c0a557 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -644,7 +644,6 @@ pub fn handle_code_action( let line_index = world.analysis().file_line_index(file_id)?; let range = params.range.conv_with(&line_index); - let assists = world.analysis().assists(FileRange { file_id, range })?.into_iter(); let diagnostics = world.analysis().diagnostics(file_id)?; let mut res = CodeActionResponse::default(); @@ -697,14 +696,19 @@ pub fn handle_code_action( res.push(action.into()); } - for assist in assists { - let title = assist.change.label.clone(); + for assist in world.analysis().assists(FileRange { file_id, range })?.into_iter() { + let title = assist.label.clone(); let edit = assist.change.try_conv_with(&world)?; + let alternative_edits = assist + .alternative_changes + .into_iter() + .map(|change| change.try_conv_with(&world)) + .collect::>>()?; let command = Command { title, command: "rust-analyzer.applySourceChange".to_string(), - arguments: Some(vec![to_value(edit).unwrap()]), + arguments: Some(vec![to_value(edit).unwrap(), to_value(alternative_edits).unwrap()]), }; let action = CodeAction { title: command.title.clone(), -- cgit v1.2.3