diff options
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 12 | ||||
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 5 |
2 files changed, 7 insertions, 10 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 4f6f250d6..f198b1f25 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -555,7 +555,7 @@ pub(crate) fn handle_runnables( | |||
555 | if should_skip_target(&runnable, cargo_spec.as_ref()) { | 555 | if should_skip_target(&runnable, cargo_spec.as_ref()) { |
556 | continue; | 556 | continue; |
557 | } | 557 | } |
558 | let mut runnable = to_proto::runnable(&snap, file_id, runnable)?; | 558 | let mut runnable = to_proto::runnable(&snap, runnable)?; |
559 | if expect_test { | 559 | if expect_test { |
560 | runnable.label = format!("{} + expect", runnable.label); | 560 | runnable.label = format!("{} + expect", runnable.label); |
561 | runnable.args.expect_test = Some(true); | 561 | runnable.args.expect_test = Some(true); |
@@ -773,7 +773,7 @@ pub(crate) fn handle_hover( | |||
773 | contents: HoverContents::Markup(to_proto::markup_content(info.info.markup)), | 773 | contents: HoverContents::Markup(to_proto::markup_content(info.info.markup)), |
774 | range: Some(range), | 774 | range: Some(range), |
775 | }, | 775 | }, |
776 | actions: prepare_hover_actions(&snap, position.file_id, &info.info.actions), | 776 | actions: prepare_hover_actions(&snap, &info.info.actions), |
777 | }; | 777 | }; |
778 | 778 | ||
779 | Ok(Some(hover)) | 779 | Ok(Some(hover)) |
@@ -1438,17 +1438,16 @@ fn show_impl_command_link( | |||
1438 | 1438 | ||
1439 | fn runnable_action_links( | 1439 | fn runnable_action_links( |
1440 | snap: &GlobalStateSnapshot, | 1440 | snap: &GlobalStateSnapshot, |
1441 | file_id: FileId, | ||
1442 | runnable: Runnable, | 1441 | runnable: Runnable, |
1443 | ) -> Option<lsp_ext::CommandLinkGroup> { | 1442 | ) -> Option<lsp_ext::CommandLinkGroup> { |
1444 | let cargo_spec = CargoTargetSpec::for_file(&snap, file_id).ok()?; | 1443 | let cargo_spec = CargoTargetSpec::for_file(&snap, runnable.nav.file_id).ok()?; |
1445 | let hover_config = snap.config.hover(); | 1444 | let hover_config = snap.config.hover(); |
1446 | if !hover_config.runnable() || should_skip_target(&runnable, cargo_spec.as_ref()) { | 1445 | if !hover_config.runnable() || should_skip_target(&runnable, cargo_spec.as_ref()) { |
1447 | return None; | 1446 | return None; |
1448 | } | 1447 | } |
1449 | 1448 | ||
1450 | let action: &'static _ = runnable.action(); | 1449 | let action: &'static _ = runnable.action(); |
1451 | to_proto::runnable(snap, file_id, runnable).ok().map(|r| { | 1450 | to_proto::runnable(snap, runnable).ok().map(|r| { |
1452 | let mut group = lsp_ext::CommandLinkGroup::default(); | 1451 | let mut group = lsp_ext::CommandLinkGroup::default(); |
1453 | 1452 | ||
1454 | if hover_config.run { | 1453 | if hover_config.run { |
@@ -1487,7 +1486,6 @@ fn goto_type_action_links( | |||
1487 | 1486 | ||
1488 | fn prepare_hover_actions( | 1487 | fn prepare_hover_actions( |
1489 | snap: &GlobalStateSnapshot, | 1488 | snap: &GlobalStateSnapshot, |
1490 | file_id: FileId, | ||
1491 | actions: &[HoverAction], | 1489 | actions: &[HoverAction], |
1492 | ) -> Vec<lsp_ext::CommandLinkGroup> { | 1490 | ) -> Vec<lsp_ext::CommandLinkGroup> { |
1493 | if snap.config.hover().none() || !snap.config.hover_actions() { | 1491 | if snap.config.hover().none() || !snap.config.hover_actions() { |
@@ -1498,7 +1496,7 @@ fn prepare_hover_actions( | |||
1498 | .iter() | 1496 | .iter() |
1499 | .filter_map(|it| match it { | 1497 | .filter_map(|it| match it { |
1500 | HoverAction::Implementation(position) => show_impl_command_link(snap, position), | 1498 | HoverAction::Implementation(position) => show_impl_command_link(snap, position), |
1501 | HoverAction::Runnable(r) => runnable_action_links(snap, file_id, r.clone()), | 1499 | HoverAction::Runnable(r) => runnable_action_links(snap, r.clone()), |
1502 | HoverAction::GoToType(targets) => goto_type_action_links(snap, targets), | 1500 | HoverAction::GoToType(targets) => goto_type_action_links(snap, targets), |
1503 | }) | 1501 | }) |
1504 | .collect() | 1502 | .collect() |
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 70cb7fbab..e8fd9bb28 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -828,11 +828,10 @@ pub(crate) fn resolved_code_action( | |||
828 | 828 | ||
829 | pub(crate) fn runnable( | 829 | pub(crate) fn runnable( |
830 | snap: &GlobalStateSnapshot, | 830 | snap: &GlobalStateSnapshot, |
831 | file_id: FileId, | ||
832 | runnable: Runnable, | 831 | runnable: Runnable, |
833 | ) -> Result<lsp_ext::Runnable> { | 832 | ) -> Result<lsp_ext::Runnable> { |
834 | let config = snap.config.runnables(); | 833 | let config = snap.config.runnables(); |
835 | let spec = CargoTargetSpec::for_file(snap, file_id)?; | 834 | let spec = CargoTargetSpec::for_file(snap, runnable.nav.file_id)?; |
836 | let workspace_root = spec.as_ref().map(|it| it.workspace_root.clone()); | 835 | let workspace_root = spec.as_ref().map(|it| it.workspace_root.clone()); |
837 | let target = spec.as_ref().map(|s| s.target.clone()); | 836 | let target = spec.as_ref().map(|s| s.target.clone()); |
838 | let (cargo_args, executable_args) = | 837 | let (cargo_args, executable_args) = |
@@ -865,7 +864,7 @@ pub(crate) fn code_lens( | |||
865 | let annotation_range = range(&line_index, annotation.range); | 864 | let annotation_range = range(&line_index, annotation.range); |
866 | 865 | ||
867 | let action = run.action(); | 866 | let action = run.action(); |
868 | let r = runnable(&snap, run.nav.file_id, run)?; | 867 | let r = runnable(&snap, run)?; |
869 | 868 | ||
870 | let command = if debug { | 869 | let command = if debug { |
871 | command::debug_single(&r) | 870 | command::debug_single(&r) |