Add Editor::remove_blocks
This commit is contained in:
parent
5d8ed535be
commit
a86ba57983
4 changed files with 16 additions and 14 deletions
|
@ -5,13 +5,11 @@ mod wrap_map;
|
||||||
|
|
||||||
use crate::{Anchor, MultiBuffer, MultiBufferSnapshot, ToOffset, ToPoint};
|
use crate::{Anchor, MultiBuffer, MultiBufferSnapshot, ToOffset, ToPoint};
|
||||||
use block_map::{BlockMap, BlockPoint};
|
use block_map::{BlockMap, BlockPoint};
|
||||||
|
use collections::{HashMap, HashSet};
|
||||||
use fold_map::{FoldMap, ToFoldPoint as _};
|
use fold_map::{FoldMap, ToFoldPoint as _};
|
||||||
use gpui::{fonts::FontId, Entity, ModelContext, ModelHandle};
|
use gpui::{fonts::FontId, Entity, ModelContext, ModelHandle};
|
||||||
use language::{Point, Subscription as BufferSubscription};
|
use language::{Point, Subscription as BufferSubscription};
|
||||||
use std::{
|
use std::ops::Range;
|
||||||
collections::{HashMap, HashSet},
|
|
||||||
ops::Range,
|
|
||||||
};
|
|
||||||
use sum_tree::Bias;
|
use sum_tree::Bias;
|
||||||
use tab_map::TabMap;
|
use tab_map::TabMap;
|
||||||
use theme::SyntaxTheme;
|
use theme::SyntaxTheme;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use super::wrap_map::{self, WrapEdit, WrapPoint, WrapSnapshot};
|
use super::wrap_map::{self, WrapEdit, WrapPoint, WrapSnapshot};
|
||||||
use crate::{Anchor, ToOffset, ToPoint as _};
|
use crate::{Anchor, ToOffset, ToPoint as _};
|
||||||
|
use collections::{HashMap, HashSet};
|
||||||
use gpui::{AppContext, ElementBox};
|
use gpui::{AppContext, ElementBox};
|
||||||
use language::Chunk;
|
use language::Chunk;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{self, Ordering},
|
cmp::{self, Ordering},
|
||||||
collections::{HashMap, HashSet},
|
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
ops::{Deref, Range},
|
ops::{Deref, Range},
|
||||||
sync::{
|
sync::{
|
||||||
|
|
|
@ -9,6 +9,7 @@ mod test;
|
||||||
|
|
||||||
use aho_corasick::AhoCorasick;
|
use aho_corasick::AhoCorasick;
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
|
use collections::{HashMap, HashSet};
|
||||||
pub use display_map::DisplayPoint;
|
pub use display_map::DisplayPoint;
|
||||||
use display_map::*;
|
use display_map::*;
|
||||||
pub use element::*;
|
pub use element::*;
|
||||||
|
@ -27,7 +28,7 @@ use language::{
|
||||||
BracketPair, Buffer, Diagnostic, DiagnosticSeverity, Language, Point, Selection, SelectionGoal,
|
BracketPair, Buffer, Diagnostic, DiagnosticSeverity, Language, Point, Selection, SelectionGoal,
|
||||||
TransactionId,
|
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 multi_buffer::{AnchorRangeExt, MultiBufferChunks, MultiBufferSnapshot, ToOffset, ToPoint};
|
||||||
use postage::watch;
|
use postage::watch;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -35,7 +36,6 @@ use smallvec::SmallVec;
|
||||||
use smol::Timer;
|
use smol::Timer;
|
||||||
use std::{
|
use std::{
|
||||||
cmp,
|
cmp,
|
||||||
collections::HashMap,
|
|
||||||
iter::{self, FromIterator},
|
iter::{self, FromIterator},
|
||||||
mem,
|
mem,
|
||||||
ops::{Deref, Range, RangeInclusive, Sub},
|
ops::{Deref, Range, RangeInclusive, Sub},
|
||||||
|
@ -2893,7 +2893,7 @@ impl Editor {
|
||||||
|
|
||||||
if is_valid != active_diagnostics.is_valid {
|
if is_valid != active_diagnostics.is_valid {
|
||||||
active_diagnostics.is_valid = 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 {
|
for (block_id, diagnostic) in &active_diagnostics.blocks {
|
||||||
new_styles.insert(
|
new_styles.insert(
|
||||||
*block_id,
|
*block_id,
|
||||||
|
@ -3051,7 +3051,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut result = HashMap::new();
|
let mut result = HashMap::default();
|
||||||
|
|
||||||
result.insert(
|
result.insert(
|
||||||
self.replica_id(cx),
|
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>(
|
pub fn insert_blocks<P>(
|
||||||
&mut self,
|
&mut self,
|
||||||
blocks: impl IntoIterator<Item = BlockProperties<P>>,
|
blocks: impl IntoIterator<Item = BlockProperties<P>>,
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use crate::display_map::{BlockContext, ToDisplayPoint};
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
display_map::{BlockContext, ToDisplayPoint},
|
||||||
DisplayPoint, Editor, EditorMode, EditorSettings, EditorSnapshot, EditorStyle, Input, Scroll,
|
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 clock::ReplicaId;
|
||||||
|
use collections::{BTreeMap, HashMap};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
color::Color,
|
color::Color,
|
||||||
geometry::{
|
geometry::{
|
||||||
|
@ -24,7 +23,6 @@ use language::Chunk;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{self, Ordering},
|
cmp::{self, Ordering},
|
||||||
collections::{BTreeMap, HashMap},
|
|
||||||
fmt::Write,
|
fmt::Write,
|
||||||
ops::Range,
|
ops::Range,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue