WIP
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use language::{Bias, BufferSnapshot, ReplicaId};
|
||||
use gpui::{Context, Model};
|
||||
use language::{Buffer, BufferSnapshot, ReplicaId};
|
||||
use std::{
|
||||
fmt::{self, Debug, Formatter},
|
||||
ops::Range,
|
||||
@@ -6,7 +7,7 @@ use std::{
|
||||
};
|
||||
use sum_tree::{SumTree, TreeMap};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
struct BufferId {
|
||||
remote_id: text::BufferId,
|
||||
replica_id: ReplicaId,
|
||||
@@ -16,6 +17,22 @@ pub struct MultiBuffer {
|
||||
snapshot: MultiBufferSnapshot,
|
||||
}
|
||||
|
||||
impl MultiBuffer {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
snapshot: MultiBufferSnapshot::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_excerpts<T>(
|
||||
&mut self,
|
||||
new_excerpts: impl IntoIterator<Item = (Model<Buffer>, Range<T>)>,
|
||||
) {
|
||||
let mut new_excerpts = new_excerpts.into_iter().collect::<Vec<_>>();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MultiBufferSnapshot {
|
||||
excerpts: SumTree<Excerpt>,
|
||||
snapshots: TreeMap<BufferId, BufferSnapshot>,
|
||||
@@ -68,3 +85,22 @@ impl sum_tree::Summary for ExcerptSummary {
|
||||
self.max_key = summary.max_key.clone();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use gpui::AppContext;
|
||||
use language::Buffer;
|
||||
|
||||
#[gpui::test]
|
||||
fn test_insert_excerpts(cx: &mut AppContext) {
|
||||
let buffer1 = cx.new_model(|cx| Buffer::local("abc\ndef\nghi", cx));
|
||||
let buffer2 = cx.new_model(|cx| Buffer::local("jkl\nmno\npqr", cx));
|
||||
|
||||
let multi = cx.new_model(|cx| {
|
||||
let mut multi = MultiBuffer::new();
|
||||
multi.insert_excerpts(vec![(buffer1.clone(), 0..4), (buffer2.clone(), 8..11)]);
|
||||
multi
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user