Make inline and regular diagnostics more related (#34237)
Release Notes: - N/A
This commit is contained in:
parent
7588280915
commit
a1188848ef
3 changed files with 26 additions and 9 deletions
|
@ -110,6 +110,7 @@ impl LanguageServerHealthStatus {
|
|||
|
||||
impl LanguageServerState {
|
||||
fn fill_menu(&self, mut menu: ContextMenu, cx: &mut Context<Self>) -> ContextMenu {
|
||||
menu = menu.align_popover_bottom();
|
||||
let lsp_logs = cx
|
||||
.try_global::<GlobalLogStore>()
|
||||
.and_then(|lsp_logs| lsp_logs.0.upgrade());
|
||||
|
|
|
@ -159,6 +159,7 @@ pub struct ContextMenu {
|
|||
keep_open_on_confirm: bool,
|
||||
documentation_aside: Option<(usize, DocumentationAside)>,
|
||||
fixed_width: Option<DefiniteLength>,
|
||||
align_popover_top: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
|
@ -215,6 +216,7 @@ impl ContextMenu {
|
|||
key_context: "menu".into(),
|
||||
_on_blur_subscription,
|
||||
keep_open_on_confirm: false,
|
||||
align_popover_top: true,
|
||||
documentation_aside: None,
|
||||
fixed_width: None,
|
||||
end_slot_action: None,
|
||||
|
@ -257,6 +259,7 @@ impl ContextMenu {
|
|||
key_context: "menu".into(),
|
||||
_on_blur_subscription,
|
||||
keep_open_on_confirm: true,
|
||||
align_popover_top: true,
|
||||
documentation_aside: None,
|
||||
fixed_width: None,
|
||||
end_slot_action: None,
|
||||
|
@ -297,6 +300,7 @@ impl ContextMenu {
|
|||
|this: &mut ContextMenu, window, cx| this.cancel(&menu::Cancel, window, cx),
|
||||
),
|
||||
keep_open_on_confirm: false,
|
||||
align_popover_top: true,
|
||||
documentation_aside: None,
|
||||
fixed_width: None,
|
||||
end_slot_action: None,
|
||||
|
@ -778,6 +782,11 @@ impl ContextMenu {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn align_popover_bottom(mut self) -> Self {
|
||||
self.align_popover_top = false;
|
||||
self
|
||||
}
|
||||
|
||||
fn render_menu_item(
|
||||
&self,
|
||||
ix: usize,
|
||||
|
@ -1100,7 +1109,13 @@ impl Render for ContextMenu {
|
|||
.when(is_wide_window, |this| this.flex_row())
|
||||
.when(!is_wide_window, |this| this.flex_col())
|
||||
.w_full()
|
||||
.items_start()
|
||||
.map(|div| {
|
||||
if self.align_popover_top {
|
||||
div.items_start()
|
||||
} else {
|
||||
div.items_end()
|
||||
}
|
||||
})
|
||||
.gap_1()
|
||||
.child(div().children(aside.clone().and_then(|(_, aside)| {
|
||||
(aside.side == DocumentationSide::Left).then(|| render_aside(aside, cx))
|
||||
|
|
|
@ -409,12 +409,10 @@ impl Render for QuickActionBar {
|
|||
);
|
||||
|
||||
if supports_inline_diagnostics {
|
||||
menu = menu.toggleable_entry(
|
||||
"Inline Diagnostics",
|
||||
inline_diagnostics_enabled,
|
||||
IconPosition::Start,
|
||||
Some(ToggleInlineDiagnostics.boxed_clone()),
|
||||
{
|
||||
let mut inline_diagnostics_item = ContextMenuEntry::new("Inline Diagnostics")
|
||||
.toggleable(IconPosition::Start, diagnostics_enabled && inline_diagnostics_enabled)
|
||||
.action(ToggleInlineDiagnostics.boxed_clone())
|
||||
.handler({
|
||||
let editor = editor.clone();
|
||||
move |window, cx| {
|
||||
editor
|
||||
|
@ -427,8 +425,11 @@ impl Render for QuickActionBar {
|
|||
})
|
||||
.ok();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
if !diagnostics_enabled {
|
||||
inline_diagnostics_item = inline_diagnostics_item.disabled(true).documentation_aside(DocumentationSide::Left, |_| Label::new("Inline diagnostics are not available until regular diagnostics are enabled.").into_any_element());
|
||||
}
|
||||
menu = menu.item(inline_diagnostics_item)
|
||||
}
|
||||
|
||||
menu = menu.separator();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue