Add basic infrastructure for inlay hints map
This commit is contained in:
parent
6e3d1b962a
commit
2ead3de7de
6 changed files with 366 additions and 85 deletions
|
@ -10,7 +10,6 @@ doctest = false
|
|||
|
||||
[features]
|
||||
test-support = [
|
||||
"rand",
|
||||
"copilot/test-support",
|
||||
"text/test-support",
|
||||
"language/test-support",
|
||||
|
@ -57,7 +56,7 @@ ordered-float.workspace = true
|
|||
parking_lot.workspace = true
|
||||
postage.workspace = true
|
||||
pulldown-cmark = { version = "0.9.2", default-features = false }
|
||||
rand = { workspace = true, optional = true }
|
||||
rand = { workspace = true }
|
||||
schemars.workspace = true
|
||||
serde.workspace = true
|
||||
serde_derive.workspace = true
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
mod block_map;
|
||||
mod editor_addition_map;
|
||||
mod fold_map;
|
||||
mod suggestion_map;
|
||||
mod tab_map;
|
||||
|
@ -7,6 +8,7 @@ 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,
|
||||
|
@ -45,6 +47,7 @@ pub struct DisplayMap {
|
|||
buffer_subscription: BufferSubscription,
|
||||
fold_map: FoldMap,
|
||||
suggestion_map: SuggestionMap,
|
||||
editor_addition_map: EditorAdditionMap,
|
||||
tab_map: TabMap,
|
||||
wrap_map: ModelHandle<WrapMap>,
|
||||
block_map: BlockMap,
|
||||
|
@ -71,6 +74,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 (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);
|
||||
|
@ -80,6 +84,7 @@ impl DisplayMap {
|
|||
buffer_subscription,
|
||||
fold_map,
|
||||
suggestion_map,
|
||||
editor_addition_map,
|
||||
tab_map,
|
||||
wrap_map,
|
||||
block_map,
|
||||
|
@ -93,11 +98,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
|
||||
.sync(suggestion_snapshot.clone(), edits);
|
||||
let tab_size = Self::tab_size(&self.buffer, cx);
|
||||
let (tab_snapshot, edits) = self
|
||||
.tab_map
|
||||
.sync(suggestion_snapshot.clone(), edits, tab_size);
|
||||
let (tab_snapshot, edits) =
|
||||
self.tab_map
|
||||
.sync(editor_addition_snapshot.clone(), edits, tab_size);
|
||||
let (wrap_snapshot, edits) = self
|
||||
.wrap_map
|
||||
.update(cx, |map, cx| map.sync(tab_snapshot.clone(), edits, cx));
|
||||
|
@ -107,6 +114,7 @@ impl DisplayMap {
|
|||
buffer_snapshot: self.buffer.read(cx).snapshot(cx),
|
||||
fold_snapshot,
|
||||
suggestion_snapshot,
|
||||
editor_addition_snapshot,
|
||||
tab_snapshot,
|
||||
wrap_snapshot,
|
||||
block_snapshot,
|
||||
|
@ -134,6 +142,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.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -141,6 +150,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.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -159,6 +169,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.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -166,6 +177,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.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -183,6 +195,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.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -201,6 +214,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.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -249,6 +263,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.tab_map.sync(snapshot, edits, tab_size);
|
||||
let (snapshot, edits) = self
|
||||
.wrap_map
|
||||
|
@ -289,6 +304,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,
|
||||
tab_snapshot: tab_map::TabSnapshot,
|
||||
wrap_snapshot: wrap_map::WrapSnapshot,
|
||||
block_snapshot: block_map::BlockSnapshot,
|
||||
|
@ -366,7 +382,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 tab_point = self.tab_snapshot.to_tab_point(suggestion_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 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)
|
||||
|
@ -376,7 +395,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 suggestion_point = self.tab_snapshot.to_suggestion_point(tab_point, bias).0;
|
||||
let editor_addition_point = self
|
||||
.tab_snapshot
|
||||
.to_editor_addition_point(tab_point, bias)
|
||||
.0;
|
||||
let suggestion_point = self
|
||||
.editor_addition_snapshot
|
||||
.to_suggestion_point(editor_addition_point, bias);
|
||||
let fold_point = self.suggestion_snapshot.to_fold_point(suggestion_point);
|
||||
fold_point.to_buffer_point(&self.fold_snapshot)
|
||||
}
|
||||
|
@ -790,7 +815,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 suggestion_point = map.tab_snapshot.to_suggestion_point(tab_point, bias).0;
|
||||
let editor_addition_point = map.tab_snapshot.to_editor_addition_point(tab_point, bias).0;
|
||||
let suggestion_point = map
|
||||
.editor_addition_snapshot
|
||||
.to_suggestion_point(editor_addition_point, bias);
|
||||
let fold_point = map.suggestion_snapshot.to_fold_point(suggestion_point);
|
||||
fold_point.to_buffer_offset(&map.fold_snapshot)
|
||||
}
|
||||
|
|
|
@ -989,6 +989,7 @@ fn offset_for_row(s: &str, target: u32) -> (u32, usize) {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::display_map::editor_addition_map::EditorAdditionMap;
|
||||
use crate::display_map::suggestion_map::SuggestionMap;
|
||||
use crate::display_map::{fold_map::FoldMap, tab_map::TabMap, wrap_map::WrapMap};
|
||||
use crate::multi_buffer::MultiBuffer;
|
||||
|
@ -1032,7 +1033,9 @@ mod tests {
|
|||
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
||||
let (fold_map, fold_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
||||
let (suggestion_map, suggestion_snapshot) = SuggestionMap::new(fold_snapshot);
|
||||
let (tab_map, tab_snapshot) = TabMap::new(suggestion_snapshot, 1.try_into().unwrap());
|
||||
let (editor_addition_map, editor_addition_snapshot) =
|
||||
EditorAdditionMap::new(suggestion_snapshot);
|
||||
let (tab_map, tab_snapshot) = TabMap::new(editor_addition_snapshot, 1.try_into().unwrap());
|
||||
let (wrap_map, wraps_snapshot) = WrapMap::new(tab_snapshot, font_id, 14.0, None, cx);
|
||||
let mut block_map = BlockMap::new(wraps_snapshot.clone(), 1, 1);
|
||||
|
||||
|
@ -1179,8 +1182,13 @@ mod tests {
|
|||
fold_map.read(buffer_snapshot, subscription.consume().into_inner());
|
||||
let (suggestion_snapshot, suggestion_edits) =
|
||||
suggestion_map.sync(fold_snapshot, fold_edits);
|
||||
let (tab_snapshot, tab_edits) =
|
||||
tab_map.sync(suggestion_snapshot, suggestion_edits, 4.try_into().unwrap());
|
||||
let (editor_addition_snapshot, editor_addition_edits) =
|
||||
editor_addition_map.sync(suggestion_snapshot, suggestion_edits);
|
||||
let (tab_snapshot, tab_edits) = tab_map.sync(
|
||||
editor_addition_snapshot,
|
||||
editor_addition_edits,
|
||||
4.try_into().unwrap(),
|
||||
);
|
||||
let (wraps_snapshot, wrap_edits) = wrap_map.update(cx, |wrap_map, cx| {
|
||||
wrap_map.sync(tab_snapshot, tab_edits, cx)
|
||||
});
|
||||
|
@ -1207,7 +1215,8 @@ mod tests {
|
|||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (_, fold_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
||||
let (_, suggestion_snapshot) = SuggestionMap::new(fold_snapshot);
|
||||
let (_, tab_snapshot) = TabMap::new(suggestion_snapshot, 1.try_into().unwrap());
|
||||
let (_, editor_addition_snapshot) = EditorAdditionMap::new(suggestion_snapshot);
|
||||
let (_, tab_snapshot) = TabMap::new(editor_addition_snapshot, 4.try_into().unwrap());
|
||||
let (_, wraps_snapshot) = WrapMap::new(tab_snapshot, font_id, 14.0, Some(60.), cx);
|
||||
let mut block_map = BlockMap::new(wraps_snapshot.clone(), 1, 1);
|
||||
|
||||
|
@ -1279,7 +1288,9 @@ mod tests {
|
|||
let mut buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (fold_map, fold_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
||||
let (suggestion_map, suggestion_snapshot) = SuggestionMap::new(fold_snapshot);
|
||||
let (tab_map, tab_snapshot) = TabMap::new(suggestion_snapshot, tab_size);
|
||||
let (editor_addition_map, editor_addition_snapshot) =
|
||||
EditorAdditionMap::new(suggestion_snapshot);
|
||||
let (tab_map, tab_snapshot) = TabMap::new(editor_addition_snapshot, 4.try_into().unwrap());
|
||||
let (wrap_map, wraps_snapshot) =
|
||||
WrapMap::new(tab_snapshot, font_id, font_size, wrap_width, cx);
|
||||
let mut block_map = BlockMap::new(
|
||||
|
@ -1336,8 +1347,10 @@ mod tests {
|
|||
fold_map.read(buffer_snapshot.clone(), vec![]);
|
||||
let (suggestion_snapshot, suggestion_edits) =
|
||||
suggestion_map.sync(fold_snapshot, fold_edits);
|
||||
let (editor_addition_snapshot, editor_addition_edits) =
|
||||
editor_addition_map.sync(suggestion_snapshot, suggestion_edits);
|
||||
let (tab_snapshot, tab_edits) =
|
||||
tab_map.sync(suggestion_snapshot, suggestion_edits, tab_size);
|
||||
tab_map.sync(editor_addition_snapshot, editor_addition_edits, tab_size);
|
||||
let (wraps_snapshot, wrap_edits) = wrap_map.update(cx, |wrap_map, cx| {
|
||||
wrap_map.sync(tab_snapshot, tab_edits, cx)
|
||||
});
|
||||
|
@ -1361,8 +1374,10 @@ mod tests {
|
|||
fold_map.read(buffer_snapshot.clone(), vec![]);
|
||||
let (suggestion_snapshot, suggestion_edits) =
|
||||
suggestion_map.sync(fold_snapshot, fold_edits);
|
||||
let (editor_addition_snapshot, editor_addition_edits) =
|
||||
editor_addition_map.sync(suggestion_snapshot, suggestion_edits);
|
||||
let (tab_snapshot, tab_edits) =
|
||||
tab_map.sync(suggestion_snapshot, suggestion_edits, tab_size);
|
||||
tab_map.sync(editor_addition_snapshot, editor_addition_edits, tab_size);
|
||||
let (wraps_snapshot, wrap_edits) = wrap_map.update(cx, |wrap_map, cx| {
|
||||
wrap_map.sync(tab_snapshot, tab_edits, cx)
|
||||
});
|
||||
|
@ -1384,8 +1399,10 @@ mod tests {
|
|||
let (fold_snapshot, fold_edits) = fold_map.read(buffer_snapshot.clone(), buffer_edits);
|
||||
let (suggestion_snapshot, suggestion_edits) =
|
||||
suggestion_map.sync(fold_snapshot, fold_edits);
|
||||
let (editor_addition_snapshot, editor_addition_edits) =
|
||||
editor_addition_map.sync(suggestion_snapshot, suggestion_edits);
|
||||
let (tab_snapshot, tab_edits) =
|
||||
tab_map.sync(suggestion_snapshot, suggestion_edits, tab_size);
|
||||
tab_map.sync(editor_addition_snapshot, editor_addition_edits, tab_size);
|
||||
let (wraps_snapshot, wrap_edits) = wrap_map.update(cx, |wrap_map, cx| {
|
||||
wrap_map.sync(tab_snapshot, tab_edits, cx)
|
||||
});
|
||||
|
|
176
crates/editor/src/display_map/editor_addition_map.rs
Normal file
176
crates/editor/src/display_map/editor_addition_map.rs
Normal file
|
@ -0,0 +1,176 @@
|
|||
#![allow(unused)]
|
||||
// TODO kb
|
||||
|
||||
use std::ops::{Add, AddAssign, Range, Sub};
|
||||
|
||||
use crate::MultiBufferSnapshot;
|
||||
|
||||
use super::{
|
||||
suggestion_map::{SuggestionEdit, SuggestionPoint, SuggestionSnapshot},
|
||||
TextHighlights,
|
||||
};
|
||||
use gpui::fonts::HighlightStyle;
|
||||
use language::{Chunk, Edit, Point, TextSummary};
|
||||
use rand::Rng;
|
||||
use sum_tree::Bias;
|
||||
|
||||
pub struct EditorAdditionMap;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct EditorAdditionSnapshot {
|
||||
// TODO kb merge these two together
|
||||
pub suggestion_snapshot: SuggestionSnapshot,
|
||||
pub version: usize,
|
||||
}
|
||||
|
||||
pub type EditorAdditionEdit = Edit<EditorAdditionOffset>;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||
pub struct EditorAdditionOffset(pub usize);
|
||||
|
||||
impl Add for EditorAdditionOffset {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: Self) -> Self::Output {
|
||||
Self(self.0 + rhs.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub for EditorAdditionOffset {
|
||||
type Output = Self;
|
||||
|
||||
fn sub(self, rhs: Self) -> Self::Output {
|
||||
Self(self.0 - rhs.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign for EditorAdditionOffset {
|
||||
fn add_assign(&mut self, rhs: Self) {
|
||||
self.0 += rhs.0;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||
pub struct EditorAdditionPoint(pub Point);
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct EditorAdditionBufferRows<'a> {
|
||||
_z: &'a std::marker::PhantomData<()>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct EditorAdditionChunks<'a> {
|
||||
_z: &'a std::marker::PhantomData<()>,
|
||||
}
|
||||
|
||||
impl<'a> Iterator for EditorAdditionChunks<'a> {
|
||||
type Item = Chunk<'a>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Iterator for EditorAdditionBufferRows<'a> {
|
||||
type Item = Option<u32>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
}
|
||||
|
||||
impl EditorAdditionPoint {
|
||||
pub fn new(row: u32, column: u32) -> Self {
|
||||
Self(Point::new(row, column))
|
||||
}
|
||||
|
||||
pub fn row(self) -> u32 {
|
||||
self.0.row
|
||||
}
|
||||
|
||||
pub fn column(self) -> u32 {
|
||||
self.0.column
|
||||
}
|
||||
}
|
||||
|
||||
impl EditorAdditionMap {
|
||||
pub fn new(suggestion_snapshot: SuggestionSnapshot) -> (Self, EditorAdditionSnapshot) {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
pub fn sync(
|
||||
&self,
|
||||
suggestion_snapshot: SuggestionSnapshot,
|
||||
suggestion_edits: Vec<SuggestionEdit>,
|
||||
) -> (EditorAdditionSnapshot, Vec<EditorAdditionEdit>) {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
pub fn randomly_mutate(
|
||||
&self,
|
||||
rng: &mut impl Rng,
|
||||
) -> (EditorAdditionSnapshot, Vec<EditorAdditionEdit>) {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
}
|
||||
|
||||
impl EditorAdditionSnapshot {
|
||||
pub fn buffer_snapshot(&self) -> &MultiBufferSnapshot {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
pub fn to_point(&self, offset: EditorAdditionOffset) -> EditorAdditionPoint {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
pub fn max_point(&self) -> EditorAdditionPoint {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
pub fn to_offset(&self, point: EditorAdditionPoint) -> EditorAdditionOffset {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
pub fn chars_at(&self, start: EditorAdditionPoint) -> impl '_ + Iterator<Item = char> {
|
||||
Vec::new().into_iter()
|
||||
}
|
||||
|
||||
pub fn to_suggestion_point(&self, point: EditorAdditionPoint, bias: Bias) -> SuggestionPoint {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
pub fn to_editor_addition_point(&self, point: SuggestionPoint) -> EditorAdditionPoint {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
pub fn clip_point(&self, point: EditorAdditionPoint, bias: Bias) -> EditorAdditionPoint {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
pub fn text_summary_for_range(&self, range: Range<EditorAdditionPoint>) -> TextSummary {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
pub fn buffer_rows<'a>(&'a self, row: u32) -> EditorAdditionBufferRows<'a> {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
pub fn line_len(&self, row: u32) -> u32 {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
pub fn chunks<'a>(
|
||||
&'a self,
|
||||
range: Range<EditorAdditionOffset>,
|
||||
language_aware: bool,
|
||||
text_highlights: Option<&'a TextHighlights>,
|
||||
suggestion_highlight: Option<HighlightStyle>,
|
||||
) -> EditorAdditionChunks<'a> {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn text(&self) -> String {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
use super::{
|
||||
suggestion_map::{self, SuggestionChunks, SuggestionEdit, SuggestionPoint, SuggestionSnapshot},
|
||||
editor_addition_map::{
|
||||
self, EditorAdditionChunks, EditorAdditionEdit, EditorAdditionPoint, EditorAdditionSnapshot,
|
||||
},
|
||||
TextHighlights,
|
||||
};
|
||||
use crate::MultiBufferSnapshot;
|
||||
|
@ -14,9 +16,9 @@ const MAX_EXPANSION_COLUMN: u32 = 256;
|
|||
pub struct TabMap(Mutex<TabSnapshot>);
|
||||
|
||||
impl TabMap {
|
||||
pub fn new(input: SuggestionSnapshot, tab_size: NonZeroU32) -> (Self, TabSnapshot) {
|
||||
pub fn new(input: EditorAdditionSnapshot, tab_size: NonZeroU32) -> (Self, TabSnapshot) {
|
||||
let snapshot = TabSnapshot {
|
||||
suggestion_snapshot: input,
|
||||
editor_addition_snapshot: input,
|
||||
tab_size,
|
||||
max_expansion_column: MAX_EXPANSION_COLUMN,
|
||||
version: 0,
|
||||
|
@ -32,19 +34,21 @@ impl TabMap {
|
|||
|
||||
pub fn sync(
|
||||
&self,
|
||||
suggestion_snapshot: SuggestionSnapshot,
|
||||
mut suggestion_edits: Vec<SuggestionEdit>,
|
||||
editor_addition_snapshot: EditorAdditionSnapshot,
|
||||
mut suggestion_edits: Vec<EditorAdditionEdit>,
|
||||
tab_size: NonZeroU32,
|
||||
) -> (TabSnapshot, Vec<TabEdit>) {
|
||||
let mut old_snapshot = self.0.lock();
|
||||
let mut new_snapshot = TabSnapshot {
|
||||
suggestion_snapshot,
|
||||
editor_addition_snapshot,
|
||||
tab_size,
|
||||
max_expansion_column: old_snapshot.max_expansion_column,
|
||||
version: old_snapshot.version,
|
||||
};
|
||||
|
||||
if old_snapshot.suggestion_snapshot.version != new_snapshot.suggestion_snapshot.version {
|
||||
if old_snapshot.editor_addition_snapshot.version
|
||||
!= new_snapshot.editor_addition_snapshot.version
|
||||
{
|
||||
new_snapshot.version += 1;
|
||||
}
|
||||
|
||||
|
@ -56,21 +60,21 @@ impl TabMap {
|
|||
// boundary.
|
||||
for suggestion_edit in &mut suggestion_edits {
|
||||
let old_end = old_snapshot
|
||||
.suggestion_snapshot
|
||||
.editor_addition_snapshot
|
||||
.to_point(suggestion_edit.old.end);
|
||||
let old_end_row_successor_offset =
|
||||
old_snapshot.suggestion_snapshot.to_offset(cmp::min(
|
||||
SuggestionPoint::new(old_end.row() + 1, 0),
|
||||
old_snapshot.suggestion_snapshot.max_point(),
|
||||
old_snapshot.editor_addition_snapshot.to_offset(cmp::min(
|
||||
EditorAdditionPoint::new(old_end.row() + 1, 0),
|
||||
old_snapshot.editor_addition_snapshot.max_point(),
|
||||
));
|
||||
let new_end = new_snapshot
|
||||
.suggestion_snapshot
|
||||
.editor_addition_snapshot
|
||||
.to_point(suggestion_edit.new.end);
|
||||
|
||||
let mut offset_from_edit = 0;
|
||||
let mut first_tab_offset = None;
|
||||
let mut last_tab_with_changed_expansion_offset = None;
|
||||
'outer: for chunk in old_snapshot.suggestion_snapshot.chunks(
|
||||
'outer: for chunk in old_snapshot.editor_addition_snapshot.chunks(
|
||||
suggestion_edit.old.end..old_end_row_successor_offset,
|
||||
false,
|
||||
None,
|
||||
|
@ -124,16 +128,16 @@ impl TabMap {
|
|||
|
||||
for suggestion_edit in suggestion_edits {
|
||||
let old_start = old_snapshot
|
||||
.suggestion_snapshot
|
||||
.editor_addition_snapshot
|
||||
.to_point(suggestion_edit.old.start);
|
||||
let old_end = old_snapshot
|
||||
.suggestion_snapshot
|
||||
.editor_addition_snapshot
|
||||
.to_point(suggestion_edit.old.end);
|
||||
let new_start = new_snapshot
|
||||
.suggestion_snapshot
|
||||
.editor_addition_snapshot
|
||||
.to_point(suggestion_edit.new.start);
|
||||
let new_end = new_snapshot
|
||||
.suggestion_snapshot
|
||||
.editor_addition_snapshot
|
||||
.to_point(suggestion_edit.new.end);
|
||||
tab_edits.push(TabEdit {
|
||||
old: old_snapshot.to_tab_point(old_start)..old_snapshot.to_tab_point(old_end),
|
||||
|
@ -155,7 +159,7 @@ impl TabMap {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct TabSnapshot {
|
||||
pub suggestion_snapshot: SuggestionSnapshot,
|
||||
pub editor_addition_snapshot: EditorAdditionSnapshot,
|
||||
pub tab_size: NonZeroU32,
|
||||
pub max_expansion_column: u32,
|
||||
pub version: usize,
|
||||
|
@ -163,15 +167,15 @@ pub struct TabSnapshot {
|
|||
|
||||
impl TabSnapshot {
|
||||
pub fn buffer_snapshot(&self) -> &MultiBufferSnapshot {
|
||||
self.suggestion_snapshot.buffer_snapshot()
|
||||
self.editor_addition_snapshot.buffer_snapshot()
|
||||
}
|
||||
|
||||
pub fn line_len(&self, row: u32) -> u32 {
|
||||
let max_point = self.max_point();
|
||||
if row < max_point.row() {
|
||||
self.to_tab_point(SuggestionPoint::new(
|
||||
self.to_tab_point(EditorAdditionPoint::new(
|
||||
row,
|
||||
self.suggestion_snapshot.line_len(row),
|
||||
self.editor_addition_snapshot.line_len(row),
|
||||
))
|
||||
.0
|
||||
.column
|
||||
|
@ -185,10 +189,10 @@ impl TabSnapshot {
|
|||
}
|
||||
|
||||
pub fn text_summary_for_range(&self, range: Range<TabPoint>) -> TextSummary {
|
||||
let input_start = self.to_suggestion_point(range.start, Bias::Left).0;
|
||||
let input_end = self.to_suggestion_point(range.end, Bias::Right).0;
|
||||
let input_start = self.to_editor_addition_point(range.start, Bias::Left).0;
|
||||
let input_end = self.to_editor_addition_point(range.end, Bias::Right).0;
|
||||
let input_summary = self
|
||||
.suggestion_snapshot
|
||||
.editor_addition_snapshot
|
||||
.text_summary_for_range(input_start..input_end);
|
||||
|
||||
let mut first_line_chars = 0;
|
||||
|
@ -241,12 +245,12 @@ impl TabSnapshot {
|
|||
suggestion_highlight: Option<HighlightStyle>,
|
||||
) -> TabChunks<'a> {
|
||||
let (input_start, expanded_char_column, to_next_stop) =
|
||||
self.to_suggestion_point(range.start, Bias::Left);
|
||||
self.to_editor_addition_point(range.start, Bias::Left);
|
||||
let input_column = input_start.column();
|
||||
let input_start = self.suggestion_snapshot.to_offset(input_start);
|
||||
let input_start = self.editor_addition_snapshot.to_offset(input_start);
|
||||
let input_end = self
|
||||
.suggestion_snapshot
|
||||
.to_offset(self.to_suggestion_point(range.end, Bias::Right).0);
|
||||
.editor_addition_snapshot
|
||||
.to_offset(self.to_editor_addition_point(range.end, Bias::Right).0);
|
||||
let to_next_stop = if range.start.0 + Point::new(0, to_next_stop) > range.end.0 {
|
||||
range.end.column() - range.start.column()
|
||||
} else {
|
||||
|
@ -254,7 +258,7 @@ impl TabSnapshot {
|
|||
};
|
||||
|
||||
TabChunks {
|
||||
suggestion_chunks: self.suggestion_snapshot.chunks(
|
||||
editor_addition_chunks: self.editor_addition_snapshot.chunks(
|
||||
input_start..input_end,
|
||||
language_aware,
|
||||
text_highlights,
|
||||
|
@ -275,8 +279,8 @@ impl TabSnapshot {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn buffer_rows(&self, row: u32) -> suggestion_map::SuggestionBufferRows {
|
||||
self.suggestion_snapshot.buffer_rows(row)
|
||||
pub fn buffer_rows(&self, row: u32) -> editor_addition_map::EditorAdditionBufferRows<'_> {
|
||||
self.editor_addition_snapshot.buffer_rows(row)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -287,33 +291,37 @@ impl TabSnapshot {
|
|||
}
|
||||
|
||||
pub fn max_point(&self) -> TabPoint {
|
||||
self.to_tab_point(self.suggestion_snapshot.max_point())
|
||||
self.to_tab_point(self.editor_addition_snapshot.max_point())
|
||||
}
|
||||
|
||||
pub fn clip_point(&self, point: TabPoint, bias: Bias) -> TabPoint {
|
||||
self.to_tab_point(
|
||||
self.suggestion_snapshot
|
||||
.clip_point(self.to_suggestion_point(point, bias).0, bias),
|
||||
self.editor_addition_snapshot
|
||||
.clip_point(self.to_editor_addition_point(point, bias).0, bias),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn to_tab_point(&self, input: SuggestionPoint) -> TabPoint {
|
||||
pub fn to_tab_point(&self, input: EditorAdditionPoint) -> TabPoint {
|
||||
let chars = self
|
||||
.suggestion_snapshot
|
||||
.chars_at(SuggestionPoint::new(input.row(), 0));
|
||||
.editor_addition_snapshot
|
||||
.chars_at(EditorAdditionPoint::new(input.row(), 0));
|
||||
let expanded = self.expand_tabs(chars, input.column());
|
||||
TabPoint::new(input.row(), expanded)
|
||||
}
|
||||
|
||||
pub fn to_suggestion_point(&self, output: TabPoint, bias: Bias) -> (SuggestionPoint, u32, u32) {
|
||||
pub fn to_editor_addition_point(
|
||||
&self,
|
||||
output: TabPoint,
|
||||
bias: Bias,
|
||||
) -> (EditorAdditionPoint, u32, u32) {
|
||||
let chars = self
|
||||
.suggestion_snapshot
|
||||
.chars_at(SuggestionPoint::new(output.row(), 0));
|
||||
.editor_addition_snapshot
|
||||
.chars_at(EditorAdditionPoint::new(output.row(), 0));
|
||||
let expanded = output.column();
|
||||
let (collapsed, expanded_char_column, to_next_stop) =
|
||||
self.collapse_tabs(chars, expanded, bias);
|
||||
(
|
||||
SuggestionPoint::new(output.row(), collapsed as u32),
|
||||
EditorAdditionPoint::new(output.row(), collapsed as u32),
|
||||
expanded_char_column,
|
||||
to_next_stop,
|
||||
)
|
||||
|
@ -321,17 +329,35 @@ impl TabSnapshot {
|
|||
|
||||
pub fn make_tab_point(&self, point: Point, bias: Bias) -> TabPoint {
|
||||
let fold_point = self
|
||||
.editor_addition_snapshot
|
||||
.suggestion_snapshot
|
||||
.fold_snapshot
|
||||
.to_fold_point(point, bias);
|
||||
let suggestion_point = self.suggestion_snapshot.to_suggestion_point(fold_point);
|
||||
self.to_tab_point(suggestion_point)
|
||||
let suggestion_point = self
|
||||
.editor_addition_snapshot
|
||||
.suggestion_snapshot
|
||||
.to_suggestion_point(fold_point);
|
||||
let editor_addition_point = self
|
||||
.editor_addition_snapshot
|
||||
.to_editor_addition_point(suggestion_point);
|
||||
self.to_tab_point(editor_addition_point)
|
||||
}
|
||||
|
||||
pub fn to_point(&self, point: TabPoint, bias: Bias) -> Point {
|
||||
let suggestion_point = self.to_suggestion_point(point, bias).0;
|
||||
let fold_point = self.suggestion_snapshot.to_fold_point(suggestion_point);
|
||||
fold_point.to_buffer_point(&self.suggestion_snapshot.fold_snapshot)
|
||||
let editor_addition_point = self.to_editor_addition_point(point, bias).0;
|
||||
let suggestion_point = self
|
||||
.editor_addition_snapshot
|
||||
.to_suggestion_point(editor_addition_point, bias);
|
||||
let fold_point = self
|
||||
.editor_addition_snapshot
|
||||
.suggestion_snapshot
|
||||
.to_fold_point(suggestion_point);
|
||||
fold_point.to_buffer_point(
|
||||
&self
|
||||
.editor_addition_snapshot
|
||||
.suggestion_snapshot
|
||||
.fold_snapshot,
|
||||
)
|
||||
}
|
||||
|
||||
fn expand_tabs(&self, chars: impl Iterator<Item = char>, column: u32) -> u32 {
|
||||
|
@ -490,7 +516,7 @@ impl<'a> std::ops::AddAssign<&'a Self> for TextSummary {
|
|||
const SPACES: &str = " ";
|
||||
|
||||
pub struct TabChunks<'a> {
|
||||
suggestion_chunks: SuggestionChunks<'a>,
|
||||
editor_addition_chunks: EditorAdditionChunks<'a>,
|
||||
chunk: Chunk<'a>,
|
||||
column: u32,
|
||||
max_expansion_column: u32,
|
||||
|
@ -506,7 +532,7 @@ impl<'a> Iterator for TabChunks<'a> {
|
|||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if self.chunk.text.is_empty() {
|
||||
if let Some(chunk) = self.suggestion_chunks.next() {
|
||||
if let Some(chunk) = self.editor_addition_chunks.next() {
|
||||
self.chunk = chunk;
|
||||
if self.inside_leading_tab {
|
||||
self.chunk.text = &self.chunk.text[1..];
|
||||
|
@ -574,7 +600,10 @@ impl<'a> Iterator for TabChunks<'a> {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
display_map::{fold_map::FoldMap, suggestion_map::SuggestionMap},
|
||||
display_map::{
|
||||
editor_addition_map::EditorAdditionMap, fold_map::FoldMap,
|
||||
suggestion_map::SuggestionMap,
|
||||
},
|
||||
MultiBuffer,
|
||||
};
|
||||
use rand::{prelude::StdRng, Rng};
|
||||
|
@ -585,7 +614,8 @@ mod tests {
|
|||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (_, fold_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
||||
let (_, suggestion_snapshot) = SuggestionMap::new(fold_snapshot);
|
||||
let (_, tab_snapshot) = TabMap::new(suggestion_snapshot, 4.try_into().unwrap());
|
||||
let (_, editor_addition_snapshot) = EditorAdditionMap::new(suggestion_snapshot);
|
||||
let (_, tab_snapshot) = TabMap::new(editor_addition_snapshot, 4.try_into().unwrap());
|
||||
|
||||
assert_eq!(tab_snapshot.expand_tabs("\t".chars(), 0), 0);
|
||||
assert_eq!(tab_snapshot.expand_tabs("\t".chars(), 1), 4);
|
||||
|
@ -602,7 +632,8 @@ mod tests {
|
|||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (_, fold_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
||||
let (_, suggestion_snapshot) = SuggestionMap::new(fold_snapshot);
|
||||
let (_, mut tab_snapshot) = TabMap::new(suggestion_snapshot, 4.try_into().unwrap());
|
||||
let (_, editor_addition_snapshot) = EditorAdditionMap::new(suggestion_snapshot);
|
||||
let (_, mut tab_snapshot) = TabMap::new(editor_addition_snapshot, 4.try_into().unwrap());
|
||||
|
||||
tab_snapshot.max_expansion_column = max_expansion_column;
|
||||
assert_eq!(tab_snapshot.text(), output);
|
||||
|
@ -626,15 +657,15 @@ mod tests {
|
|||
let input_point = Point::new(0, ix as u32);
|
||||
let output_point = Point::new(0, output.find(c).unwrap() as u32);
|
||||
assert_eq!(
|
||||
tab_snapshot.to_tab_point(SuggestionPoint(input_point)),
|
||||
tab_snapshot.to_tab_point(EditorAdditionPoint(input_point)),
|
||||
TabPoint(output_point),
|
||||
"to_tab_point({input_point:?})"
|
||||
);
|
||||
assert_eq!(
|
||||
tab_snapshot
|
||||
.to_suggestion_point(TabPoint(output_point), Bias::Left)
|
||||
.to_editor_addition_point(TabPoint(output_point), Bias::Left)
|
||||
.0,
|
||||
SuggestionPoint(input_point),
|
||||
EditorAdditionPoint(input_point),
|
||||
"to_suggestion_point({output_point:?})"
|
||||
);
|
||||
}
|
||||
|
@ -650,7 +681,8 @@ mod tests {
|
|||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (_, fold_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
||||
let (_, suggestion_snapshot) = SuggestionMap::new(fold_snapshot);
|
||||
let (_, mut tab_snapshot) = TabMap::new(suggestion_snapshot, 4.try_into().unwrap());
|
||||
let (_, editor_addition_snapshot) = EditorAdditionMap::new(suggestion_snapshot);
|
||||
let (_, mut tab_snapshot) = TabMap::new(editor_addition_snapshot, 4.try_into().unwrap());
|
||||
|
||||
tab_snapshot.max_expansion_column = max_expansion_column;
|
||||
assert_eq!(tab_snapshot.text(), input);
|
||||
|
@ -664,7 +696,8 @@ mod tests {
|
|||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (_, fold_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
||||
let (_, suggestion_snapshot) = SuggestionMap::new(fold_snapshot);
|
||||
let (_, tab_snapshot) = TabMap::new(suggestion_snapshot, 4.try_into().unwrap());
|
||||
let (_, editor_addition_snapshot) = EditorAdditionMap::new(suggestion_snapshot);
|
||||
let (_, tab_snapshot) = TabMap::new(editor_addition_snapshot, 4.try_into().unwrap());
|
||||
|
||||
assert_eq!(
|
||||
chunks(&tab_snapshot, TabPoint::zero()),
|
||||
|
@ -728,6 +761,9 @@ mod tests {
|
|||
let (suggestion_map, _) = SuggestionMap::new(fold_snapshot);
|
||||
let (suggestion_snapshot, _) = suggestion_map.randomly_mutate(&mut rng);
|
||||
log::info!("SuggestionMap text: {:?}", suggestion_snapshot.text());
|
||||
let (editor_addition_map, _) = EditorAdditionMap::new(suggestion_snapshot.clone());
|
||||
let (suggestion_snapshot, _) = editor_addition_map.randomly_mutate(&mut rng);
|
||||
log::info!("EditorAdditionMap text: {:?}", suggestion_snapshot.text());
|
||||
|
||||
let (tab_map, _) = TabMap::new(suggestion_snapshot.clone(), tab_size);
|
||||
let tabs_snapshot = tab_map.set_max_expansion_column(32);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::{
|
||||
suggestion_map::SuggestionBufferRows,
|
||||
editor_addition_map::EditorAdditionBufferRows,
|
||||
tab_map::{self, TabEdit, TabPoint, TabSnapshot},
|
||||
TextHighlights,
|
||||
};
|
||||
|
@ -65,7 +65,7 @@ pub struct WrapChunks<'a> {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct WrapBufferRows<'a> {
|
||||
input_buffer_rows: SuggestionBufferRows<'a>,
|
||||
input_buffer_rows: EditorAdditionBufferRows<'a>,
|
||||
input_buffer_row: Option<u32>,
|
||||
output_row: u32,
|
||||
soft_wrapped: bool,
|
||||
|
@ -762,19 +762,29 @@ impl WrapSnapshot {
|
|||
let mut prev_fold_row = 0;
|
||||
for display_row in 0..=self.max_point().row() {
|
||||
let tab_point = self.to_tab_point(WrapPoint::new(display_row, 0));
|
||||
let editor_addition_point = self
|
||||
.tab_snapshot
|
||||
.to_editor_addition_point(tab_point, Bias::Left)
|
||||
.0;
|
||||
let suggestion_point = self
|
||||
.tab_snapshot
|
||||
.to_suggestion_point(tab_point, Bias::Left)
|
||||
.0;
|
||||
.editor_addition_snapshot
|
||||
.to_suggestion_point(editor_addition_point, Bias::Left);
|
||||
let fold_point = self
|
||||
.tab_snapshot
|
||||
.editor_addition_snapshot
|
||||
.suggestion_snapshot
|
||||
.to_fold_point(suggestion_point);
|
||||
if fold_point.row() == prev_fold_row && display_row != 0 {
|
||||
expected_buffer_rows.push(None);
|
||||
} else {
|
||||
let buffer_point = fold_point
|
||||
.to_buffer_point(&self.tab_snapshot.suggestion_snapshot.fold_snapshot);
|
||||
let buffer_point = fold_point.to_buffer_point(
|
||||
&self
|
||||
.tab_snapshot
|
||||
.editor_addition_snapshot
|
||||
.suggestion_snapshot
|
||||
.fold_snapshot,
|
||||
);
|
||||
expected_buffer_rows.push(input_buffer_rows[buffer_point.row as usize]);
|
||||
prev_fold_row = fold_point.row();
|
||||
}
|
||||
|
@ -1038,7 +1048,10 @@ fn consolidate_wrap_edits(edits: &mut Vec<WrapEdit>) {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
display_map::{fold_map::FoldMap, suggestion_map::SuggestionMap, tab_map::TabMap},
|
||||
display_map::{
|
||||
editor_addition_map::EditorAdditionMap, fold_map::FoldMap,
|
||||
suggestion_map::SuggestionMap, tab_map::TabMap,
|
||||
},
|
||||
MultiBuffer,
|
||||
};
|
||||
use gpui::test::observe;
|
||||
|
@ -1093,7 +1106,13 @@ mod tests {
|
|||
log::info!("FoldMap text: {:?}", fold_snapshot.text());
|
||||
let (suggestion_map, suggestion_snapshot) = SuggestionMap::new(fold_snapshot.clone());
|
||||
log::info!("SuggestionMap text: {:?}", suggestion_snapshot.text());
|
||||
let (tab_map, _) = TabMap::new(suggestion_snapshot.clone(), tab_size);
|
||||
let (editor_addition_map, editors_additions_snapshot) =
|
||||
EditorAdditionMap::new(suggestion_snapshot.clone());
|
||||
log::info!(
|
||||
"EditorAdditionsMap text: {:?}",
|
||||
editors_additions_snapshot.text()
|
||||
);
|
||||
let (tab_map, _) = TabMap::new(editors_additions_snapshot.clone(), tab_size);
|
||||
let tabs_snapshot = tab_map.set_max_expansion_column(32);
|
||||
log::info!("TabMap text: {:?}", tabs_snapshot.text());
|
||||
|
||||
|
@ -1141,8 +1160,10 @@ mod tests {
|
|||
for (fold_snapshot, fold_edits) in fold_map.randomly_mutate(&mut rng) {
|
||||
let (suggestion_snapshot, suggestion_edits) =
|
||||
suggestion_map.sync(fold_snapshot, fold_edits);
|
||||
let (editor_addition_snapshot, editor_addition_edits) =
|
||||
editor_addition_map.sync(suggestion_snapshot, suggestion_edits);
|
||||
let (tabs_snapshot, tab_edits) =
|
||||
tab_map.sync(suggestion_snapshot, suggestion_edits, tab_size);
|
||||
tab_map.sync(editor_addition_snapshot, editor_addition_edits, tab_size);
|
||||
let (mut snapshot, wrap_edits) =
|
||||
wrap_map.update(cx, |map, cx| map.sync(tabs_snapshot, tab_edits, cx));
|
||||
snapshot.check_invariants();
|
||||
|
@ -1153,8 +1174,10 @@ mod tests {
|
|||
40..=59 => {
|
||||
let (suggestion_snapshot, suggestion_edits) =
|
||||
suggestion_map.randomly_mutate(&mut rng);
|
||||
let (editor_addition_snapshot, editor_addition_edits) =
|
||||
editor_addition_map.sync(suggestion_snapshot, suggestion_edits);
|
||||
let (tabs_snapshot, tab_edits) =
|
||||
tab_map.sync(suggestion_snapshot, suggestion_edits, tab_size);
|
||||
tab_map.sync(editor_addition_snapshot, editor_addition_edits, tab_size);
|
||||
let (mut snapshot, wrap_edits) =
|
||||
wrap_map.update(cx, |map, cx| map.sync(tabs_snapshot, tab_edits, cx));
|
||||
snapshot.check_invariants();
|
||||
|
@ -1178,8 +1201,10 @@ mod tests {
|
|||
let (suggestion_snapshot, suggestion_edits) =
|
||||
suggestion_map.sync(fold_snapshot, fold_edits);
|
||||
log::info!("SuggestionMap text: {:?}", suggestion_snapshot.text());
|
||||
let (editor_addition_snapshot, editor_addition_edits) =
|
||||
editor_addition_map.sync(suggestion_snapshot, suggestion_edits);
|
||||
let (tabs_snapshot, tab_edits) =
|
||||
tab_map.sync(suggestion_snapshot, suggestion_edits, tab_size);
|
||||
tab_map.sync(editor_addition_snapshot, editor_addition_edits, tab_size);
|
||||
log::info!("TabMap text: {:?}", tabs_snapshot.text());
|
||||
|
||||
let unwrapped_text = tabs_snapshot.text();
|
||||
|
@ -1227,7 +1252,7 @@ mod tests {
|
|||
if tab_size.get() == 1
|
||||
|| !wrapped_snapshot
|
||||
.tab_snapshot
|
||||
.suggestion_snapshot
|
||||
.editor_addition_snapshot
|
||||
.text()
|
||||
.contains('\t')
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue