Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--helix-term/src/application.rs4
-rw-r--r--helix-term/src/events.rs5
-rw-r--r--helix-view/src/editor.rs7
-rw-r--r--helix-view/src/events.rs10
4 files changed, 21 insertions, 5 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index dd19a2d7..17b58420 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -356,6 +356,8 @@ impl Application {
}
pub fn handle_config_events(&mut self, config_event: ConfigEvent) {
+ let old_editor_config = self.editor.config();
+
match config_event {
ConfigEvent::Refresh => self.refresh_config(),
@@ -374,7 +376,7 @@ impl Application {
// Update all the relevant members in the editor after updating
// the configuration.
- self.editor.refresh_config();
+ self.editor.refresh_config(&old_editor_config);
// reset view position in case softwrap was enabled/disabled
let scrolloff = self.editor.config().scrolloff;
diff --git a/helix-term/src/events.rs b/helix-term/src/events.rs
index 80f045cd..b0a42298 100644
--- a/helix-term/src/events.rs
+++ b/helix-term/src/events.rs
@@ -1,8 +1,8 @@
use helix_event::{events, register_event};
use helix_view::document::Mode;
use helix_view::events::{
- DiagnosticsDidChange, DocumentDidChange, DocumentDidClose, DocumentDidOpen, DocumentFocusLost,
- LanguageServerExited, LanguageServerInitialized, SelectionDidChange,
+ ConfigDidChange, DiagnosticsDidChange, DocumentDidChange, DocumentDidClose, DocumentDidOpen,
+ DocumentFocusLost, LanguageServerExited, LanguageServerInitialized, SelectionDidChange,
};
use crate::commands;
@@ -26,4 +26,5 @@ pub fn register() {
register_event::<DiagnosticsDidChange>();
register_event::<LanguageServerInitialized>();
register_event::<LanguageServerExited>();
+ register_event::<ConfigDidChange>();
}
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 575a0b5f..2e5c60cf 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -1289,11 +1289,16 @@ impl Editor {
/// Call if the config has changed to let the editor update all
/// relevant members.
- pub fn refresh_config(&mut self) {
+ pub fn refresh_config(&mut self, old_config: &Config) {
let config = self.config();
self.auto_pairs = (&config.auto_pairs).into();
self.reset_idle_timer();
self._refresh();
+ helix_event::dispatch(crate::events::ConfigDidChange {
+ editor: self,
+ old: old_config,
+ new: &config,
+ })
}
pub fn clear_idle_timer(&mut self) {
diff --git a/helix-view/src/events.rs b/helix-view/src/events.rs
index 4a44beb3..0435e6a4 100644
--- a/helix-view/src/events.rs
+++ b/helix-view/src/events.rs
@@ -2,7 +2,7 @@ use helix_core::{ChangeSet, Rope};
use helix_event::events;
use helix_lsp::LanguageServerId;
-use crate::{Document, DocumentId, Editor, ViewId};
+use crate::{editor::Config, Document, DocumentId, Editor, ViewId};
events! {
DocumentDidOpen<'a> {
@@ -33,4 +33,12 @@ events! {
editor: &'a mut Editor,
server_id: LanguageServerId
}
+
+ // NOTE: this event is simple for now and is expected to change as the config system evolves.
+ // Ideally it would say what changed.
+ ConfigDidChange<'a> {
+ editor: &'a mut Editor,
+ old: &'a Config,
+ new: &'a Config
+ }
}