diff options
author | Kirill Bulatov <[email protected]> | 2020-01-01 23:39:01 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-01-15 18:16:27 +0000 |
commit | 73dc8b6f06b49f4728a50e83781c361e9a8b3100 (patch) | |
tree | 677cb7280fc39b27761bd4afd2e6294aec9d739c /crates/ra_lsp_server/src/main_loop | |
parent | 01422cc31d1917aaef4b1f402eda05abfff1e75f (diff) |
Another attempt to add multiple edits
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 12 |
1 files changed, 8 insertions, 4 deletions
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( | |||
644 | let line_index = world.analysis().file_line_index(file_id)?; | 644 | let line_index = world.analysis().file_line_index(file_id)?; |
645 | let range = params.range.conv_with(&line_index); | 645 | let range = params.range.conv_with(&line_index); |
646 | 646 | ||
647 | let assists = world.analysis().assists(FileRange { file_id, range })?.into_iter(); | ||
648 | let diagnostics = world.analysis().diagnostics(file_id)?; | 647 | let diagnostics = world.analysis().diagnostics(file_id)?; |
649 | let mut res = CodeActionResponse::default(); | 648 | let mut res = CodeActionResponse::default(); |
650 | 649 | ||
@@ -697,14 +696,19 @@ pub fn handle_code_action( | |||
697 | res.push(action.into()); | 696 | res.push(action.into()); |
698 | } | 697 | } |
699 | 698 | ||
700 | for assist in assists { | 699 | for assist in world.analysis().assists(FileRange { file_id, range })?.into_iter() { |
701 | let title = assist.change.label.clone(); | 700 | let title = assist.label.clone(); |
702 | let edit = assist.change.try_conv_with(&world)?; | 701 | let edit = assist.change.try_conv_with(&world)?; |
702 | let alternative_edits = assist | ||
703 | .alternative_changes | ||
704 | .into_iter() | ||
705 | .map(|change| change.try_conv_with(&world)) | ||
706 | .collect::<Result<Vec<_>>>()?; | ||
703 | 707 | ||
704 | let command = Command { | 708 | let command = Command { |
705 | title, | 709 | title, |
706 | command: "rust-analyzer.applySourceChange".to_string(), | 710 | command: "rust-analyzer.applySourceChange".to_string(), |
707 | arguments: Some(vec![to_value(edit).unwrap()]), | 711 | arguments: Some(vec![to_value(edit).unwrap(), to_value(alternative_edits).unwrap()]), |
708 | }; | 712 | }; |
709 | let action = CodeAction { | 713 | let action = CodeAction { |
710 | title: command.title.clone(), | 714 | title: command.title.clone(), |