Repository: helix-editor/helix
File: helix-term/src/application.rs (Rust)

Code before:
    pub fn handle_config_events(&mut self, config_event: ConfigEvent) {
        match config_event {
            ConfigEvent::Refresh => self.refresh_config(),

            // Since only the Application can make changes to Editor's config,
            // the Editor must send up a new copy of a modified config so that
            // the Application can apply it.
            ConfigEvent::Update(editor_config) => {
                let mut app_config = (*self.config.load().clone()).clone();
                app_config.editor = *editor_config;
                if let Err(err) = self.terminal.reconfigure(app_config.editor.clone().into()) {
                    self.editor.set_error(err.to_string());
                };
                self.config.store(Arc::new(app_config));
            }
        }

        // Update all the relevant members in the editor after updating
        // the configuration.
        self.editor.refresh_config();

        // reset view position in case softwrap was enabled/disabled
        let scrolloff = self.editor.config().scrolloff;
        for (view, _) in self.editor.tree.views() {
            let doc = doc_mut!(self.editor, &view.doc);
            if let Some(offset) = view.offset_coords_to_in_view_center::<false>(doc, scrolloff) {
                doc.view_data_mut(view.id).view_position = offset
            }
        }
    }

    /// refresh language config after config change
    fn refresh_language_config(&mut self) -> Result<(), Error> {
        let lang_loader = helix_core::config::user_lang_loader()?;

        self.syn_loader.store(Arc::new(lang_loader));
        self.editor.syn_loader = self.syn_loader.clone();
        for document in self.editor.documents.values_mut() {
            document.detect_language(self.syn_loader.clone());
            let diagnostics = Editor::doc_diagnostics(
                &self.editor.language_servers,
                &self.editor.diagnostics,
                document,
            );
            document.replace_diagnostics(diagnostics, &[], None);
        }

        Ok(())
    }

    /// Refresh theme after config change

Review comment (suggestion):
I would prefer to keep the ensure_cursor_in_viee function around for now. We already pass a document that to so all that would need to change od that it requires a mutable doc reference and and immutable view reference instead of the other way around

Code after:
                    }
                }
            }

            // for integration tests only, reset the idle timer after every
            // event to signal when test events are done processing
            #[cfg(feature = "integration")]
            {
                self.editor.reset_idle_timer();
            }
        }
    }

    pub fn handle_config_events(&mut self, config_event: ConfigEvent) {
        match config_event {
            ConfigEvent::Refresh => self.refresh_config(),

            // Since only the Application can make changes to Editor's config,
            // the Editor must send up a new copy of a modified config so that
            // the Application can apply it.
            ConfigEvent::Update(editor_config) => {
                let mut app_config = (*self.config.load().clone()).clone();
                app_config.editor = *editor_config;
                if let Err(err) = self.terminal.reconfigure(app_config.editor.clone().into()) {
                    self.editor.set_error(err.to_string());
                };
                self.config.store(Arc::new(app_config));
            }
        }

        // Update all the relevant members in the editor after updating
        // the configuration.
        self.editor.refresh_config();

        // reset view position in case softwrap was enabled/disabled
        let scrolloff = self.editor.config().scrolloff;
        for (view, _) in self.editor.tree.views() {
            let doc = doc_mut!(self.editor, &view.doc);
            view.ensure_cursor_in_view(doc, scrolloff);
        }
    }

    /// refresh language config after config change
    fn refresh_language_config(&mut self) -> Result<(), Error> {
        let lang_loader = helix_core::config::user_lang_loader()?;

        self.syn_loader.store(Arc::new(lang_loader));
        self.editor.syn_loader = self.syn_loader.clone();
        for document in self.editor.documents.values_mut() {
            document.detect_language(self.syn_loader.clone());
            let diagnostics = Editor::doc_diagnostics(