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

Code before:
            }
        }

        // 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 mut view_position_resets = Vec::new();
        let scrolloff = self.editor.config().scrolloff;
        for (view, _) in self.editor.tree.views() {
            let doc = &self.editor.documents[&view.doc];

            if let Some(offset) = view.offset_coords_to_in_view_center::<false>(doc, scrolloff) {
                view_position_resets.push((offset, view.id, view.doc));
            }
        }
        for (offset, view_id, doc_id) in view_position_resets {
            self.editor
                .document_mut(doc_id)
                .unwrap()
                .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
    fn refresh_theme(&mut self, config: &Config) -> Result<(), Error> {
        let true_color = config.editor.true_color || crate::true_color();
        let theme = config
            .theme
            .as_ref()

Review comment (suggestion):
I believe the borrow checker is smart enough to let us do this part without the intermediary collection:

```rust
// 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;
    }
}
```

Code after:
        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(
                &self.editor.language_servers,
                &self.editor.diagnostics,
                document,
            );
            document.replace_diagnostics(diagnostics, &[], None);
        }

        Ok(())
    }

    /// Refresh theme after config change
    fn refresh_theme(&mut self, config: &Config) -> Result<(), Error> {
        let true_color = config.editor.true_color || crate::true_color();
        let theme = config