From 87981bb2ab8429199a2d1ddcbcc3e2cdba0b5ed2 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 24 Mar 2022 08:56:37 +0100 Subject: [PATCH] Emit an `Edited` event when ending, undoing or redoing a transaction --- crates/editor/src/editor.rs | 5 +++++ crates/editor/src/items.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 19812e3083..c4808215d7 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3364,6 +3364,7 @@ impl Editor { self.set_selections(selections, None, true, cx); } self.request_autoscroll(Autoscroll::Fit, cx); + cx.emit(Event::Edited); } } @@ -3373,6 +3374,7 @@ impl Editor { self.set_selections(selections, None, true, cx); } self.request_autoscroll(Autoscroll::Fit, cx); + cx.emit(Event::Edited); } } @@ -5148,6 +5150,8 @@ impl Editor { } else { log::error!("unexpectedly ended a transaction that wasn't started by this editor"); } + + cx.emit(Event::Edited); } } @@ -5657,6 +5661,7 @@ fn compute_scroll_position( pub enum Event { Activate, BufferEdited, + Edited, Blurred, Dirtied, Saved, diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 9d3a1bd054..f10956c125 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -198,7 +198,7 @@ impl FollowableItem for Editor { fn should_unfollow_on_event(event: &Self::Event, _: &AppContext) -> bool { match event { - // Event::BufferEdited { local } => *local, + Event::Edited => true, Event::SelectionsChanged { local } => *local, Event::ScrollPositionChanged { local } => *local, _ => false,