Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Expose a `DisplayMap::replace_suggestion` method
Antonio Scandurraba3913df8c64
diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rsindex 30388291548..f49b9e34b8e 100644--- a/crates/editor/src/display_map.rs+++ b/crates/editor/src/display_map.rs@@ -16,6 +16,7 @@ use gpui::{use language::{OffsetUtf16, Point, Subscription as BufferSubscription};use settings::Settings;use std::{any::TypeId, fmt::Debug, num::NonZeroU32, ops::Range, sync::Arc};+pub use suggestion_map::Suggestion;use suggestion_map::SuggestionMap;use sum_tree::{Bias, TreeMap};use tab_map::{TabMap, TabSnapshot};@@ -229,6 +230,25 @@ impl DisplayMap {self.text_highlights.remove(&Some(type_id))}+ pub fn replace_suggestion<T>(+ &self,+ new_suggestion: Option<Suggestion<T>>,+ cx: &mut ModelContext<Self>,+ ) where+ T: ToPoint,+ {+ let snapshot = self.buffer.read(cx).snapshot(cx);+ let edits = self.buffer_subscription.consume().into_inner();+ let tab_size = Self::tab_size(&self.buffer, cx);+ let (snapshot, edits) = self.fold_map.read(snapshot, edits);+ let (snapshot, edits) = self.suggestion_map.replace(new_suggestion, snapshot, edits);+ let (snapshot, edits) = self.tab_map.sync(snapshot, edits, tab_size);+ let (snapshot, edits) = self+ .wrap_map+ .update(cx, |map, cx| map.sync(snapshot, edits, cx));+ self.block_map.read(snapshot, edits);+ }+pub fn set_font(&self, font_id: FontId, font_size: f32, cx: &mut ModelContext<Self>) -> bool {self.wrap_map.update(cx, |map, cx| map.set_font(font_id, font_size, cx))