Allow to temporarily toggle diagnostics in the editor (#30316)
* Adds a `diagnostics_max_severity: null` editor settings that has previous hardcoded default, `warning` * Make inline diagnostics to inherit this setting by default (can be overridden with its own max_severity setting) * Allows to toggle diagnostics in the editor menu and via new action, `editor::ToggleDiagnostics` Closes https://github.com/zed-industries/zed/issues/4686 Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
parent
9e5d115e72
commit
a8312d623d
12 changed files with 279 additions and 96 deletions
|
@ -5,13 +5,15 @@ use assistant_settings::AssistantSettings;
|
|||
use editor::actions::{
|
||||
AddSelectionAbove, AddSelectionBelow, DuplicateLineDown, GoToDiagnostic, GoToHunk,
|
||||
GoToPreviousDiagnostic, GoToPreviousHunk, MoveLineDown, MoveLineUp, SelectAll,
|
||||
SelectLargerSyntaxNode, SelectNext, SelectSmallerSyntaxNode, ToggleGoToLine,
|
||||
SelectLargerSyntaxNode, SelectNext, SelectSmallerSyntaxNode, ToggleDiagnostics, ToggleGoToLine,
|
||||
ToggleInlineDiagnostics,
|
||||
};
|
||||
use editor::{Editor, EditorSettings};
|
||||
use gpui::{
|
||||
Action, ClickEvent, Context, Corner, ElementId, Entity, EventEmitter, FocusHandle, Focusable,
|
||||
InteractiveElement, ParentElement, Render, Styled, Subscription, WeakEntity, Window,
|
||||
};
|
||||
use project::project_settings::DiagnosticSeverity;
|
||||
use search::{BufferSearchBar, buffer_search};
|
||||
use settings::{Settings, SettingsStore};
|
||||
use ui::{
|
||||
|
@ -91,8 +93,10 @@ impl Render for QuickActionBar {
|
|||
let selection_menu_enabled = editor_value.selection_menu_enabled(cx);
|
||||
let inlay_hints_enabled = editor_value.inlay_hints_enabled();
|
||||
let inline_values_enabled = editor_value.inline_values_enabled();
|
||||
let inline_diagnostics_enabled = editor_value.show_inline_diagnostics();
|
||||
let supports_diagnostics = editor_value.mode().is_full();
|
||||
let diagnostics_enabled = editor_value.diagnostics_max_severity != DiagnosticSeverity::Off;
|
||||
let supports_inline_diagnostics = editor_value.inline_diagnostics_enabled();
|
||||
let inline_diagnostics_enabled = editor_value.show_inline_diagnostics();
|
||||
let git_blame_inline_enabled = editor_value.git_blame_inline_enabled();
|
||||
let show_git_blame_gutter = editor_value.show_git_blame_gutter();
|
||||
let auto_signature_help_enabled = editor_value.auto_signature_help_enabled(cx);
|
||||
|
@ -248,19 +252,19 @@ impl Render for QuickActionBar {
|
|||
);
|
||||
}
|
||||
|
||||
if supports_inline_diagnostics {
|
||||
if supports_diagnostics {
|
||||
menu = menu.toggleable_entry(
|
||||
"Inline Diagnostics",
|
||||
inline_diagnostics_enabled,
|
||||
"Diagnostics",
|
||||
diagnostics_enabled,
|
||||
IconPosition::Start,
|
||||
Some(editor::actions::ToggleInlineDiagnostics.boxed_clone()),
|
||||
Some(ToggleDiagnostics.boxed_clone()),
|
||||
{
|
||||
let editor = editor.clone();
|
||||
move |window, cx| {
|
||||
editor
|
||||
.update(cx, |editor, cx| {
|
||||
editor.toggle_inline_diagnostics(
|
||||
&editor::actions::ToggleInlineDiagnostics,
|
||||
editor.toggle_diagnostics(
|
||||
&ToggleDiagnostics,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
|
@ -269,6 +273,29 @@ impl Render for QuickActionBar {
|
|||
}
|
||||
},
|
||||
);
|
||||
|
||||
if supports_inline_diagnostics {
|
||||
menu = menu.toggleable_entry(
|
||||
"Inline Diagnostics",
|
||||
inline_diagnostics_enabled,
|
||||
IconPosition::Start,
|
||||
Some(ToggleInlineDiagnostics.boxed_clone()),
|
||||
{
|
||||
let editor = editor.clone();
|
||||
move |window, cx| {
|
||||
editor
|
||||
.update(cx, |editor, cx| {
|
||||
editor.toggle_inline_diagnostics(
|
||||
&ToggleInlineDiagnostics,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if supports_minimap {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue