Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Avoid notifying editor when wrap width changes

Max Brunsfeldf5ca514bf0a2
diff --git a/crates/editor2/src/display_map/wrap_map.rs b/crates/editor2/src/display_map/wrap_map.rs
index ca9db7754ba..6a47a435a3c 100644
--- a/crates/editor2/src/display_map/wrap_map.rs
+++ b/crates/editor2/src/display_map/wrap_map.rs
@@ -184,7 +184,6 @@ impl WrapMap {
Ok((snapshot, edits)) => {
self.snapshot = snapshot;
self.edits_since_sync = self.edits_since_sync.compose(&edits);
- cx.notify();
}
Err(wrap_task) => {
self.background_task = Some(cx.spawn(|this, mut cx| async move {
diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rs
index a11f8ae2cc8..b2040aff5be 100644
--- a/crates/editor2/src/editor.rs
+++ b/crates/editor2/src/editor.rs
@@ -8300,7 +8300,9 @@ impl Editor {
self.style.as_ref()
}
- pub fn set_wrap_width(&self, width: Option<Pixels>, cx: &mut AppContext) -> bool {
+ // Called by the element. This method is not designed to be called outside of the editor
+ // element's layout code because it does not notify when rewrapping is computed synchronously.
+ pub(crate) fn set_wrap_width(&self, width: Option<Pixels>, cx: &mut AppContext) -> bool {
self.display_map
.update(cx, |map, cx| map.set_wrap_width(width, cx))
}