diff --git a/helix-term/src/handlers/diagnostics.rs b/helix-term/src/handlers/diagnostics.rs index 3e44d416d..70e8ecc2a 100644 --- a/helix-term/src/handlers/diagnostics.rs +++ b/helix-term/src/handlers/diagnostics.rs @@ -17,7 +17,9 @@ pub(super) fn register_hooks(_handlers: &Handlers) { }); register_hook!(move |event: &mut OnModeSwitch<'_, '_>| { 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(()) }); diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index b6a56cafa..13f2c5d54 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -191,7 +191,11 @@ impl EditorView { } 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 enable_cursor_line = view .diagnostics_handler @@ -235,7 +239,7 @@ impl EditorView { if config.inline_diagnostics.disabled() && config.end_of_line_diagnostics == DiagnosticFilter::Disable - && editor.config().enable_diagnostics + && config.enable_diagnostics { Self::render_diagnostics(doc, view, inner, surface, theme); } diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 74558daa7..353f0bf71 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -1649,18 +1649,15 @@ impl Editor { } Action::HorizontalSplit | Action::VerticalSplit => { // 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 .tree .try_get(self.tree.focus) .filter(|v| id == v.doc) // Different Document .cloned() - .unwrap_or_else(|| { - View::new( - id, - self.config().gutters.clone(), - self.config().enable_diagnostics, - ) - }); + .unwrap_or_else(|| View::new(id, gutters, enable_diagnostics)); let view_id = self.tree.split( view, match action { diff --git a/helix-view/src/handlers/diagnostics.rs b/helix-view/src/handlers/diagnostics.rs index d749b5920..b22e04dc6 100644 --- a/helix-view/src/handlers/diagnostics.rs +++ b/helix-view/src/handlers/diagnostics.rs @@ -59,7 +59,7 @@ pub struct DiagnosticsHandler { generation: Cell, last_doc: Cell, last_cursor_line: Cell, - pub active: bool, + pub active: Cell, pub events: Sender, } @@ -69,7 +69,7 @@ pub struct DiagnosticsHandler { // but to fix that larger architecutre changes are needed impl Clone for DiagnosticsHandler { fn clone(&self) -> Self { - Self::new(self.active) + Self::new(self.active.take()) } } @@ -88,7 +88,7 @@ impl DiagnosticsHandler { events, last_doc: Cell::new(DocumentId(NonZeroUsize::new(usize::MAX).unwrap())), 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 { - if !self.active { + if !self.active.take() { return false; } let cursor_line = doc