mirror of https://github.com/helix-editor/helix
fix: update blame when editing config
parent
647615ddec
commit
07c69c1e74
|
@ -11,6 +11,7 @@ use helix_view::{
|
||||||
align_view,
|
align_view,
|
||||||
document::{DocumentOpenError, DocumentSavedEventResult},
|
document::{DocumentOpenError, DocumentSavedEventResult},
|
||||||
editor::{ConfigEvent, EditorEvent},
|
editor::{ConfigEvent, EditorEvent},
|
||||||
|
events::EditorConfigDidChange,
|
||||||
graphics::Rect,
|
graphics::Rect,
|
||||||
theme,
|
theme,
|
||||||
tree::Layout,
|
tree::Layout,
|
||||||
|
@ -364,6 +365,11 @@ impl Application {
|
||||||
// the Application can apply it.
|
// the Application can apply it.
|
||||||
ConfigEvent::Update(editor_config) => {
|
ConfigEvent::Update(editor_config) => {
|
||||||
let mut app_config = (*self.config.load().clone()).clone();
|
let mut app_config = (*self.config.load().clone()).clone();
|
||||||
|
helix_event::dispatch(EditorConfigDidChange {
|
||||||
|
old_config: &app_config.editor,
|
||||||
|
new_config: &editor_config,
|
||||||
|
editor: &mut self.editor,
|
||||||
|
});
|
||||||
app_config.editor = *editor_config;
|
app_config.editor = *editor_config;
|
||||||
if let Err(err) = self.terminal.reconfigure(app_config.editor.clone().into()) {
|
if let Err(err) = self.terminal.reconfigure(app_config.editor.clone().into()) {
|
||||||
self.editor.set_error(err.to_string());
|
self.editor.set_error(err.to_string());
|
||||||
|
|
|
@ -2,7 +2,7 @@ use helix_event::{events, register_event};
|
||||||
use helix_view::document::Mode;
|
use helix_view::document::Mode;
|
||||||
use helix_view::events::{
|
use helix_view::events::{
|
||||||
DiagnosticsDidChange, DocumentDidChange, DocumentDidClose, DocumentDidOpen, DocumentFocusLost,
|
DiagnosticsDidChange, DocumentDidChange, DocumentDidClose, DocumentDidOpen, DocumentFocusLost,
|
||||||
LanguageServerExited, LanguageServerInitialized, SelectionDidChange,
|
EditorConfigDidChange, LanguageServerExited, LanguageServerInitialized, SelectionDidChange,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::commands;
|
use crate::commands;
|
||||||
|
@ -20,6 +20,7 @@ pub fn register() {
|
||||||
register_event::<PostCommand>();
|
register_event::<PostCommand>();
|
||||||
register_event::<DocumentDidOpen>();
|
register_event::<DocumentDidOpen>();
|
||||||
register_event::<DocumentDidChange>();
|
register_event::<DocumentDidChange>();
|
||||||
|
register_event::<EditorConfigDidChange>();
|
||||||
register_event::<DocumentDidClose>();
|
register_event::<DocumentDidClose>();
|
||||||
register_event::<DocumentFocusLost>();
|
register_event::<DocumentFocusLost>();
|
||||||
register_event::<SelectionDidChange>();
|
register_event::<SelectionDidChange>();
|
||||||
|
|
|
@ -4,7 +4,7 @@ use helix_event::register_hook;
|
||||||
use helix_vcs::FileBlame;
|
use helix_vcs::FileBlame;
|
||||||
use helix_view::{
|
use helix_view::{
|
||||||
editor::InlineBlameBehaviour,
|
editor::InlineBlameBehaviour,
|
||||||
events::DocumentDidOpen,
|
events::{DocumentDidOpen, EditorConfigDidChange},
|
||||||
handlers::{BlameEvent, Handlers},
|
handlers::{BlameEvent, Handlers},
|
||||||
DocumentId,
|
DocumentId,
|
||||||
};
|
};
|
||||||
|
@ -91,4 +91,26 @@ pub(super) fn register_hooks(handlers: &Handlers) {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
let tx = handlers.blame.clone();
|
||||||
|
register_hook!(move |event: &mut EditorConfigDidChange<'_>| {
|
||||||
|
if event.old_config.inline_blame.behaviour == InlineBlameBehaviour::Disabled
|
||||||
|
&& event.new_config.inline_blame.behaviour != InlineBlameBehaviour::Disabled
|
||||||
|
{
|
||||||
|
// request blame for all documents, since any of them could have
|
||||||
|
// outdated blame
|
||||||
|
for doc in event.editor.documents() {
|
||||||
|
if let Some(path) = doc.path() {
|
||||||
|
helix_event::send_blocking(
|
||||||
|
&tx,
|
||||||
|
BlameEvent {
|
||||||
|
path: path.to_path_buf(),
|
||||||
|
doc_id: doc.id(),
|
||||||
|
line: None,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use helix_core::{ChangeSet, Rope};
|
||||||
use helix_event::events;
|
use helix_event::events;
|
||||||
use helix_lsp::LanguageServerId;
|
use helix_lsp::LanguageServerId;
|
||||||
|
|
||||||
use crate::{Document, DocumentId, Editor, ViewId};
|
use crate::{editor::Config, Document, DocumentId, Editor, ViewId};
|
||||||
|
|
||||||
events! {
|
events! {
|
||||||
DocumentDidOpen<'a> {
|
DocumentDidOpen<'a> {
|
||||||
|
@ -17,6 +17,11 @@ events! {
|
||||||
changes: &'a ChangeSet,
|
changes: &'a ChangeSet,
|
||||||
ghost_transaction: bool
|
ghost_transaction: bool
|
||||||
}
|
}
|
||||||
|
EditorConfigDidChange<'a> {
|
||||||
|
old_config: &'a Config,
|
||||||
|
new_config: &'a Config,
|
||||||
|
editor: &'a mut Editor
|
||||||
|
}
|
||||||
DocumentDidClose<'a> {
|
DocumentDidClose<'a> {
|
||||||
editor: &'a mut Editor,
|
editor: &'a mut Editor,
|
||||||
doc: Document
|
doc: Document
|
||||||
|
|
Loading…
Reference in New Issue