mirror of https://github.com/helix-editor/helix
feat: attempt at getting config option to disable diagnostics working
parent
8271a35be2
commit
be3dea5468
|
@ -17,7 +17,9 @@ pub(super) fn register_hooks(_handlers: &Handlers) {
|
||||||
});
|
});
|
||||||
register_hook!(move |event: &mut OnModeSwitch<'_, '_>| {
|
register_hook!(move |event: &mut OnModeSwitch<'_, '_>| {
|
||||||
for (view, _) in event.cx.editor.tree.views_mut() {
|
for (view, _) in event.cx.editor.tree.views_mut() {
|
||||||
view.diagnostics_handler.active = event.new_mode != Mode::Insert;
|
view.diagnostics_handler
|
||||||
|
.active
|
||||||
|
.set(event.new_mode != Mode::Insert);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|
|
@ -191,7 +191,11 @@ impl EditorView {
|
||||||
}
|
}
|
||||||
let config = doc.config.load();
|
let config = doc.config.load();
|
||||||
|
|
||||||
if editor.config().enable_diagnostics {
|
// view.diagnostics_handler
|
||||||
|
// .active
|
||||||
|
// .set(config.enable_diagnostics);
|
||||||
|
|
||||||
|
if config.enable_diagnostics {
|
||||||
let width = view.inner_width(doc);
|
let width = view.inner_width(doc);
|
||||||
let enable_cursor_line = view
|
let enable_cursor_line = view
|
||||||
.diagnostics_handler
|
.diagnostics_handler
|
||||||
|
@ -235,7 +239,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.config().enable_diagnostics
|
&& config.enable_diagnostics
|
||||||
{
|
{
|
||||||
Self::render_diagnostics(doc, view, inner, surface, theme);
|
Self::render_diagnostics(doc, view, inner, surface, theme);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1649,18 +1649,15 @@ impl Editor {
|
||||||
}
|
}
|
||||||
Action::HorizontalSplit | Action::VerticalSplit => {
|
Action::HorizontalSplit | Action::VerticalSplit => {
|
||||||
// copy the current view, unless there is no view yet
|
// copy the current view, unless there is no view yet
|
||||||
|
let config = self.config();
|
||||||
|
let gutters = config.gutters.clone();
|
||||||
|
let enable_diagnostics = config.enable_diagnostics;
|
||||||
let view = self
|
let view = self
|
||||||
.tree
|
.tree
|
||||||
.try_get(self.tree.focus)
|
.try_get(self.tree.focus)
|
||||||
.filter(|v| id == v.doc) // Different Document
|
.filter(|v| id == v.doc) // Different Document
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| View::new(id, gutters, enable_diagnostics));
|
||||||
View::new(
|
|
||||||
id,
|
|
||||||
self.config().gutters.clone(),
|
|
||||||
self.config().enable_diagnostics,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
let view_id = self.tree.split(
|
let view_id = self.tree.split(
|
||||||
view,
|
view,
|
||||||
match action {
|
match action {
|
||||||
|
|
|
@ -59,7 +59,7 @@ pub struct DiagnosticsHandler {
|
||||||
generation: Cell<usize>,
|
generation: Cell<usize>,
|
||||||
last_doc: Cell<DocumentId>,
|
last_doc: Cell<DocumentId>,
|
||||||
last_cursor_line: Cell<usize>,
|
last_cursor_line: Cell<usize>,
|
||||||
pub active: bool,
|
pub active: Cell<bool>,
|
||||||
pub events: Sender<DiagnosticEvent>,
|
pub events: Sender<DiagnosticEvent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ pub struct DiagnosticsHandler {
|
||||||
// but to fix that larger architecutre changes are needed
|
// but to fix that larger architecutre changes are needed
|
||||||
impl Clone for DiagnosticsHandler {
|
impl Clone for DiagnosticsHandler {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self::new(self.active)
|
Self::new(self.active.take())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ impl DiagnosticsHandler {
|
||||||
events,
|
events,
|
||||||
last_doc: Cell::new(DocumentId(NonZeroUsize::new(usize::MAX).unwrap())),
|
last_doc: Cell::new(DocumentId(NonZeroUsize::new(usize::MAX).unwrap())),
|
||||||
last_cursor_line: Cell::new(usize::MAX),
|
last_cursor_line: Cell::new(usize::MAX),
|
||||||
active: enable_diagnostics,
|
active: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ impl DiagnosticsHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
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.take() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let cursor_line = doc
|
let cursor_line = doc
|
||||||
|
|
Loading…
Reference in New Issue