Skip to content

minor: simplify #9712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
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
15 changes: 6 additions & 9 deletions crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,6 @@ impl Config {
pub fn code_action_group(&self) -> bool {
self.experimental("codeActionGroup")
}
pub fn experimental_hover_actions(&self) -> bool {
self.experimental("hoverActions")
}
pub fn server_status_notification(&self) -> bool {
self.experimental("serverStatusNotification")
}
Expand Down Expand Up @@ -790,13 +787,13 @@ impl Config {
}
}
pub fn hover_actions(&self) -> HoverActionsConfig {
let enable = self.experimental("hoverActions") && self.data.hoverActions_enable;
HoverActionsConfig {
implementations: self.data.hoverActions_enable
&& self.data.hoverActions_implementations,
references: self.data.hoverActions_enable && self.data.hoverActions_references,
run: self.data.hoverActions_enable && self.data.hoverActions_run,
debug: self.data.hoverActions_enable && self.data.hoverActions_debug,
goto_type_def: self.data.hoverActions_enable && self.data.hoverActions_gotoTypeDef,
implementations: enable && self.data.hoverActions_implementations,
references: enable && self.data.hoverActions_references,
run: enable && self.data.hoverActions_run,
debug: enable && self.data.hoverActions_debug,
goto_type_def: enable && self.data.hoverActions_gotoTypeDef,
}
}
pub fn highlighting_strings(&self) -> bool {
Expand Down
10 changes: 5 additions & 5 deletions crates/rust-analyzer/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,11 @@ pub(crate) fn handle_hover(
contents: HoverContents::Markup(to_proto::markup_content(info.info.markup)),
range: Some(range),
},
actions: prepare_hover_actions(&snap, &info.info.actions),
actions: if snap.config.hover_actions().none() {
Vec::new()
} else {
prepare_hover_actions(&snap, &info.info.actions)
},
};

Ok(Some(hover))
Expand Down Expand Up @@ -1594,10 +1598,6 @@ fn prepare_hover_actions(
snap: &GlobalStateSnapshot,
actions: &[HoverAction],
) -> Vec<lsp_ext::CommandLinkGroup> {
if snap.config.hover_actions().none() || !snap.config.experimental_hover_actions() {
return Vec::new();
}

actions
.iter()
.filter_map(|it| match it {
Expand Down