mirror of https://github.com/helix-editor/helix
feat: add `:toggle-diagnostics` command to hide diagnostics
parent
0dce39e0df
commit
a1a2cce23e
|
@ -1940,8 +1940,8 @@ fn toggle_diagnostics(
|
||||||
ensure!(args.is_empty(), ":toggle-diagnostics takes no arguments");
|
ensure!(args.is_empty(), ":toggle-diagnostics takes no arguments");
|
||||||
|
|
||||||
let (view, _) = current!(cx.editor);
|
let (view, _) = current!(cx.editor);
|
||||||
|
view.diagnostics_handler.toggle_active();
|
||||||
view.diagnostics_handler.toggle_diagnostics();
|
cx.editor.toggle_diagnostics();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,19 +189,26 @@ impl EditorView {
|
||||||
primary_cursor,
|
primary_cursor,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let width = view.inner_width(doc);
|
|
||||||
let config = doc.config.load();
|
let config = doc.config.load();
|
||||||
let enable_cursor_line = view
|
|
||||||
.diagnostics_handler
|
if editor.show_diagnostics {
|
||||||
.show_cursorline_diagnostics(doc, view.id);
|
log::error!("{:#?}", editor.show_diagnostics);
|
||||||
let inline_diagnostic_config = config.inline_diagnostics.prepare(width, enable_cursor_line);
|
let width = view.inner_width(doc);
|
||||||
decorations.add_decoration(InlineDiagnostics::new(
|
let enable_cursor_line = view
|
||||||
doc,
|
.diagnostics_handler
|
||||||
theme,
|
.show_cursorline_diagnostics(doc, view.id);
|
||||||
primary_cursor,
|
let inline_diagnostic_config =
|
||||||
inline_diagnostic_config,
|
config.inline_diagnostics.prepare(width, enable_cursor_line);
|
||||||
config.end_of_line_diagnostics,
|
|
||||||
));
|
decorations.add_decoration(InlineDiagnostics::new(
|
||||||
|
doc,
|
||||||
|
theme,
|
||||||
|
primary_cursor,
|
||||||
|
inline_diagnostic_config,
|
||||||
|
config.end_of_line_diagnostics,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
render_document(
|
render_document(
|
||||||
surface,
|
surface,
|
||||||
inner,
|
inner,
|
||||||
|
@ -229,6 +236,7 @@ impl EditorView {
|
||||||
|
|
||||||
if config.inline_diagnostics.disabled()
|
if config.inline_diagnostics.disabled()
|
||||||
&& config.end_of_line_diagnostics == DiagnosticFilter::Disable
|
&& config.end_of_line_diagnostics == DiagnosticFilter::Disable
|
||||||
|
&& editor.show_diagnostics
|
||||||
{
|
{
|
||||||
Self::render_diagnostics(doc, view, inner, surface, theme);
|
Self::render_diagnostics(doc, view, inner, surface, theme);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,7 @@ impl Renderer<'_, '_> {
|
||||||
end_col - start_col
|
end_col - start_col
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// need to toggle this
|
||||||
fn draw_diagnostic(&mut self, diag: &Diagnostic, col: u16, next_severity: Option<Severity>) {
|
fn draw_diagnostic(&mut self, diag: &Diagnostic, col: u16, next_severity: Option<Severity>) {
|
||||||
let severity = diag.severity();
|
let severity = diag.severity();
|
||||||
let (sym, sym_severity) = if let Some(next_severity) = next_severity {
|
let (sym, sym_severity) = if let Some(next_severity) = next_severity {
|
||||||
|
|
|
@ -94,9 +94,6 @@ impl DiagnosticsHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DiagnosticsHandler {
|
impl DiagnosticsHandler {
|
||||||
pub fn toggle_diagnostics(&mut self) {
|
|
||||||
self.active = !self.active;
|
|
||||||
}
|
|
||||||
pub fn immediately_show_diagnostic(&self, doc: &Document, view: ViewId) {
|
pub fn immediately_show_diagnostic(&self, doc: &Document, view: ViewId) {
|
||||||
self.last_doc.set(doc.id());
|
self.last_doc.set(doc.id());
|
||||||
let cursor_line = doc
|
let cursor_line = doc
|
||||||
|
@ -107,6 +104,11 @@ impl DiagnosticsHandler {
|
||||||
self.active_generation
|
self.active_generation
|
||||||
.store(self.generation.get(), atomic::Ordering::Relaxed);
|
.store(self.generation.get(), atomic::Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn toggle_active(&mut self) {
|
||||||
|
self.active = !self.active;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn show_cursorline_diagnostics(&self, doc: &Document, view: ViewId) -> bool {
|
pub fn show_cursorline_diagnostics(&self, doc: &Document, view: ViewId) -> bool {
|
||||||
if !self.active {
|
if !self.active {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue