Add Editor::remove_blocks

This commit is contained in:
Max Brunsfeld 2021-12-22 17:30:14 -08:00
parent 5d8ed535be
commit a86ba57983
4 changed files with 16 additions and 14 deletions

View File

@ -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;

View File

@ -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::{

View File

@ -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<BlockId>, cx: &mut ViewContext<Self>) {
self.display_map.update(cx, |display_map, cx| {
display_map.remove_blocks(block_ids, cx)
});
}
pub fn insert_blocks<P>(
&mut self,
blocks: impl IntoIterator<Item = BlockProperties<P>>,

View File

@ -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,
};