Rename the new map
This commit is contained in:
parent
9287634548
commit
b5233b3ad5
5 changed files with 190 additions and 211 deletions
|
@ -1,6 +1,6 @@
|
|||
mod block_map;
|
||||
mod editor_addition_map;
|
||||
mod fold_map;
|
||||
mod inlay_map;
|
||||
mod suggestion_map;
|
||||
mod tab_map;
|
||||
mod wrap_map;
|
||||
|
@ -8,13 +8,13 @@ mod wrap_map;
|
|||
use crate::{Anchor, AnchorRangeExt, MultiBuffer, MultiBufferSnapshot, ToOffset, ToPoint};
|
||||
pub use block_map::{BlockMap, BlockPoint};
|
||||
use collections::{HashMap, HashSet};
|
||||
use editor_addition_map::EditorAdditionMap;
|
||||
use fold_map::{FoldMap, FoldOffset};
|
||||
use gpui::{
|
||||
color::Color,
|
||||
fonts::{FontId, HighlightStyle},
|
||||
Entity, ModelContext, ModelHandle,
|
||||
};
|
||||
use inlay_map::InlayMap;
|
||||
use language::{
|
||||
language_settings::language_settings, OffsetUtf16, Point, Subscription as BufferSubscription,
|
||||
};
|
||||
|
@ -30,7 +30,7 @@ pub use block_map::{
|
|||
BlockDisposition, BlockId, BlockProperties, BlockStyle, RenderBlock, TransformBlock,
|
||||
};
|
||||
|
||||
use self::editor_addition_map::InlayHintToRender;
|
||||
use self::inlay_map::InlayHintToRender;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum FoldStatus {
|
||||
|
@ -49,7 +49,7 @@ pub struct DisplayMap {
|
|||
buffer_subscription: BufferSubscription,
|
||||
fold_map: FoldMap,
|
||||
suggestion_map: SuggestionMap,
|
||||
editor_addition_map: EditorAdditionMap,
|
||||
inlay_map: InlayMap,
|
||||
tab_map: TabMap,
|
||||
wrap_map: ModelHandle<WrapMap>,
|
||||
block_map: BlockMap,
|
||||
|
@ -76,7 +76,7 @@ impl DisplayMap {
|
|||
let tab_size = Self::tab_size(&buffer, cx);
|
||||
let (fold_map, snapshot) = FoldMap::new(buffer.read(cx).snapshot(cx));
|
||||
let (suggestion_map, snapshot) = SuggestionMap::new(snapshot);
|
||||
let (editor_addition_map, snapshot) = EditorAdditionMap::new(snapshot);
|
||||
let (inlay_map, snapshot) = InlayMap::new(snapshot);
|
||||
let (tab_map, snapshot) = TabMap::new(snapshot, tab_size);
|
||||
let (wrap_map, snapshot) = WrapMap::new(snapshot, font_id, font_size, wrap_width, cx);
|
||||
let block_map = BlockMap::new(snapshot, buffer_header_height, excerpt_header_height);
|
||||
|
@ -86,7 +86,7 @@ impl DisplayMap {
|
|||
buffer_subscription,
|
||||
fold_map,
|
||||
suggestion_map,
|
||||
editor_addition_map,
|
||||
inlay_map,
|
||||
tab_map,
|
||||
wrap_map,
|
||||
block_map,
|
||||
|
@ -100,13 +100,13 @@ impl DisplayMap {
|
|||
let edits = self.buffer_subscription.consume().into_inner();
|
||||
let (fold_snapshot, edits) = self.fold_map.read(buffer_snapshot, edits);
|
||||
let (suggestion_snapshot, edits) = self.suggestion_map.sync(fold_snapshot.clone(), edits);
|
||||
let (editor_addition_snapshot, edits) = self
|
||||
.editor_addition_map
|
||||
let (inlay_snapshot, edits) = self
|
||||
.inlay_map
|
||||
.sync(suggestion_snapshot.clone(), edits);
|
||||
let tab_size = Self::tab_size(&self.buffer, cx);
|
||||
let (tab_snapshot, edits) =
|
||||
self.tab_map
|
||||
.sync(editor_addition_snapshot.clone(), edits, tab_size);
|
||||
.sync(inlay_snapshot.clone(), edits, tab_size);
|
||||
let (wrap_snapshot, edits) = self
|
||||
.wrap_map
|
||||
.update(cx, |map, cx| map.sync(tab_snapshot.clone(), edits, cx));
|
||||
|
@ -116,7 +116,7 @@ impl DisplayMap {
|
|||
buffer_snapshot: self.buffer.read(cx).snapshot(cx),
|
||||
fold_snapshot,
|
||||
suggestion_snapshot,
|
||||
editor_addition_snapshot,
|
||||
inlay_snapshot,
|
||||
tab_snapshot,
|
||||
wrap_snapshot,
|
||||
block_snapshot,
|
||||
|
@ -144,7 +144,7 @@ impl DisplayMap {
|
|||
let tab_size = Self::tab_size(&self.buffer, cx);
|
||||
let (mut fold_map, snapshot, edits) = self.fold_map.write(snapshot, edits);
|
||||
let (snapshot, edits) = self.suggestion_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.editor_addition_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.inlay_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -152,7 +152,7 @@ impl DisplayMap {
|
|||
self.block_map.read(snapshot, edits);
|
||||
let (snapshot, edits) = fold_map.fold(ranges);
|
||||
let (snapshot, edits) = self.suggestion_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.editor_addition_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.inlay_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -171,7 +171,7 @@ impl DisplayMap {
|
|||
let tab_size = Self::tab_size(&self.buffer, cx);
|
||||
let (mut fold_map, snapshot, edits) = self.fold_map.write(snapshot, edits);
|
||||
let (snapshot, edits) = self.suggestion_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.editor_addition_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.inlay_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -179,7 +179,7 @@ impl DisplayMap {
|
|||
self.block_map.read(snapshot, edits);
|
||||
let (snapshot, edits) = fold_map.unfold(ranges, inclusive);
|
||||
let (snapshot, edits) = self.suggestion_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.editor_addition_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.inlay_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -197,7 +197,7 @@ impl DisplayMap {
|
|||
let tab_size = Self::tab_size(&self.buffer, cx);
|
||||
let (snapshot, edits) = self.fold_map.read(snapshot, edits);
|
||||
let (snapshot, edits) = self.suggestion_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.editor_addition_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.inlay_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -216,7 +216,7 @@ impl DisplayMap {
|
|||
let tab_size = Self::tab_size(&self.buffer, cx);
|
||||
let (snapshot, edits) = self.fold_map.read(snapshot, edits);
|
||||
let (snapshot, edits) = self.suggestion_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.editor_addition_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.inlay_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -265,7 +265,7 @@ impl DisplayMap {
|
|||
let (snapshot, edits) = self.fold_map.read(snapshot, edits);
|
||||
let (snapshot, edits, old_suggestion) =
|
||||
self.suggestion_map.replace(new_suggestion, snapshot, edits);
|
||||
let (snapshot, edits) = self.editor_addition_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.inlay_map.sync(snapshot, edits);
|
||||
let (snapshot, edits) = self.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -302,7 +302,7 @@ impl DisplayMap {
|
|||
.map(|buffer_handle| buffer_handle.id())
|
||||
.collect::<HashSet<_>>());
|
||||
|
||||
self.editor_addition_map.set_inlay_hints(
|
||||
self.inlay_map.set_inlay_hints(
|
||||
new_hints
|
||||
.into_iter()
|
||||
.filter_map(|hint| {
|
||||
|
@ -312,9 +312,10 @@ impl DisplayMap {
|
|||
let buffer = dbg!(multi_buffer.buffer(dbg!(hint.buffer_id)))?.read(cx);
|
||||
let snapshot = buffer.snapshot();
|
||||
Some(InlayHintToRender {
|
||||
position: editor_addition_map::EditorAdditionPoint(
|
||||
text::ToPoint::to_point(&hint.position, &snapshot),
|
||||
),
|
||||
position: inlay_map::InlayPoint(text::ToPoint::to_point(
|
||||
&hint.position,
|
||||
&snapshot,
|
||||
)),
|
||||
text: hint.text().trim_end().into(),
|
||||
})
|
||||
})
|
||||
|
@ -340,7 +341,7 @@ pub struct DisplaySnapshot {
|
|||
pub buffer_snapshot: MultiBufferSnapshot,
|
||||
fold_snapshot: fold_map::FoldSnapshot,
|
||||
suggestion_snapshot: suggestion_map::SuggestionSnapshot,
|
||||
editor_addition_snapshot: editor_addition_map::EditorAdditionSnapshot,
|
||||
inlay_snapshot: inlay_map::InlaySnapshot,
|
||||
tab_snapshot: tab_map::TabSnapshot,
|
||||
wrap_snapshot: wrap_map::WrapSnapshot,
|
||||
block_snapshot: block_map::BlockSnapshot,
|
||||
|
@ -418,10 +419,10 @@ impl DisplaySnapshot {
|
|||
fn point_to_display_point(&self, point: Point, bias: Bias) -> DisplayPoint {
|
||||
let fold_point = self.fold_snapshot.to_fold_point(point, bias);
|
||||
let suggestion_point = self.suggestion_snapshot.to_suggestion_point(fold_point);
|
||||
let editor_addition_point = self
|
||||
.editor_addition_snapshot
|
||||
.to_editor_addition_point(suggestion_point);
|
||||
let tab_point = self.tab_snapshot.to_tab_point(editor_addition_point);
|
||||
let inlay_point = self
|
||||
.inlay_snapshot
|
||||
.to_inlay_point(suggestion_point);
|
||||
let tab_point = self.tab_snapshot.to_tab_point(inlay_point);
|
||||
let wrap_point = self.wrap_snapshot.tab_point_to_wrap_point(tab_point);
|
||||
let block_point = self.block_snapshot.to_block_point(wrap_point);
|
||||
DisplayPoint(block_point)
|
||||
|
@ -431,13 +432,13 @@ impl DisplaySnapshot {
|
|||
let block_point = point.0;
|
||||
let wrap_point = self.block_snapshot.to_wrap_point(block_point);
|
||||
let tab_point = self.wrap_snapshot.to_tab_point(wrap_point);
|
||||
let editor_addition_point = self
|
||||
let inlay_point = self
|
||||
.tab_snapshot
|
||||
.to_editor_addition_point(tab_point, bias)
|
||||
.to_inlay_point(tab_point, bias)
|
||||
.0;
|
||||
let suggestion_point = self
|
||||
.editor_addition_snapshot
|
||||
.to_suggestion_point(editor_addition_point, bias);
|
||||
.inlay_snapshot
|
||||
.to_suggestion_point(inlay_point, bias);
|
||||
let fold_point = self.suggestion_snapshot.to_fold_point(suggestion_point);
|
||||
fold_point.to_buffer_point(&self.fold_snapshot)
|
||||
}
|
||||
|
@ -851,10 +852,10 @@ impl DisplayPoint {
|
|||
pub fn to_offset(self, map: &DisplaySnapshot, bias: Bias) -> usize {
|
||||
let wrap_point = map.block_snapshot.to_wrap_point(self.0);
|
||||
let tab_point = map.wrap_snapshot.to_tab_point(wrap_point);
|
||||
let editor_addition_point = map.tab_snapshot.to_editor_addition_point(tab_point, bias).0;
|
||||
let inlay_point = map.tab_snapshot.to_inlay_point(tab_point, bias).0;
|
||||
let suggestion_point = map
|
||||
.editor_addition_snapshot
|
||||
.to_suggestion_point(editor_addition_point, bias);
|
||||
.inlay_snapshot
|
||||
.to_suggestion_point(inlay_point, bias);
|
||||
let fold_point = map.suggestion_snapshot.to_fold_point(suggestion_point);
|
||||
fold_point.to_buffer_offset(&map.fold_snapshot)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue