diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index a3c95ad4bfa9ef89b9025495cd382cb72aca8aed..bcf7d14906d2a9c526ed74c29916eb40419b19c7 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -5,13 +5,11 @@ mod wrap_map; use crate::{Anchor, MultiBuffer, MultiBufferSnapshot, ToOffset, ToPoint}; use block_map::{BlockMap, BlockPoint}; +use collections::{HashMap, HashSet}; use fold_map::{FoldMap, ToFoldPoint as _}; use gpui::{fonts::FontId, Entity, ModelContext, ModelHandle}; use language::{Point, Subscription as BufferSubscription}; -use std::{ - collections::{HashMap, HashSet}, - ops::Range, -}; +use std::ops::Range; use sum_tree::Bias; use tab_map::TabMap; use theme::SyntaxTheme; diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index 5f879ef1638e08a5a14abee8eb6d36fcd3e40fac..7e0248530831cfd549d39bcf567cd1589d7a85ef 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -1,11 +1,11 @@ use super::wrap_map::{self, WrapEdit, WrapPoint, WrapSnapshot}; use crate::{Anchor, ToOffset, ToPoint as _}; +use collections::{HashMap, HashSet}; use gpui::{AppContext, ElementBox}; use language::Chunk; use parking_lot::Mutex; use std::{ cmp::{self, Ordering}, - collections::{HashMap, HashSet}, fmt::Debug, ops::{Deref, Range}, sync::{ diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index b2243a41516ac2ede06aa48ebbf64414d1377319..aa4495eed9d48bce7ea0ac6b54f61aa0ce7e533e 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -9,6 +9,7 @@ mod test; use aho_corasick::AhoCorasick; use clock::ReplicaId; +use collections::{HashMap, HashSet}; pub use display_map::DisplayPoint; use display_map::*; pub use element::*; @@ -27,7 +28,7 @@ use language::{ BracketPair, Buffer, Diagnostic, DiagnosticSeverity, Language, Point, Selection, SelectionGoal, TransactionId, }; -pub use multi_buffer::{Anchor, ExcerptProperties, MultiBuffer}; +pub use multi_buffer::{Anchor, ExcerptId, ExcerptProperties, MultiBuffer}; use multi_buffer::{AnchorRangeExt, MultiBufferChunks, MultiBufferSnapshot, ToOffset, ToPoint}; use postage::watch; use serde::{Deserialize, Serialize}; @@ -35,7 +36,6 @@ use smallvec::SmallVec; use smol::Timer; use std::{ cmp, - collections::HashMap, iter::{self, FromIterator}, mem, ops::{Deref, Range, RangeInclusive, Sub}, @@ -2893,7 +2893,7 @@ impl Editor { if is_valid != active_diagnostics.is_valid { active_diagnostics.is_valid = is_valid; - let mut new_styles = HashMap::new(); + let mut new_styles = HashMap::default(); for (block_id, diagnostic) in &active_diagnostics.blocks { new_styles.insert( *block_id, @@ -3051,7 +3051,7 @@ impl Editor { } } - let mut result = HashMap::new(); + let mut result = HashMap::default(); result.insert( self.replica_id(cx), @@ -3423,6 +3423,12 @@ impl Editor { } } + pub fn remove_blocks(&mut self, block_ids: HashSet, cx: &mut ViewContext) { + self.display_map.update(cx, |display_map, cx| { + display_map.remove_blocks(block_ids, cx) + }); + } + pub fn insert_blocks

( &mut self, blocks: impl IntoIterator>, diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 9c45207bb01ac5cf02c6f2d0deeaf37ed954ec43..cfe4a99dc4449d7b1eee7ce475053ed502cd3b69 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1,11 +1,10 @@ -use crate::display_map::{BlockContext, ToDisplayPoint}; - use super::{ + display_map::{BlockContext, ToDisplayPoint}, DisplayPoint, Editor, EditorMode, EditorSettings, EditorSnapshot, EditorStyle, Input, Scroll, - Select, SelectPhase, SoftWrap, MAX_LINE_LEN, + Select, SelectPhase, SoftWrap, ToPoint, MAX_LINE_LEN, }; -use crate::ToPoint; use clock::ReplicaId; +use collections::{BTreeMap, HashMap}; use gpui::{ color::Color, geometry::{ @@ -24,7 +23,6 @@ use language::Chunk; use smallvec::SmallVec; use std::{ cmp::{self, Ordering}, - collections::{BTreeMap, HashMap}, fmt::Write, ops::Range, };