Change Buffer constructors to construct the History internally

This commit is contained in:
Max Brunsfeld 2022-07-05 14:51:28 -07:00
parent 1add2d270e
commit 116fa92e84
3 changed files with 30 additions and 33 deletions

View file

@ -148,9 +148,9 @@ impl HistoryEntry {
}
#[derive(Clone)]
pub struct History {
struct History {
// TODO: Turn this into a String or Rope, maybe.
pub base_text: Arc<str>,
base_text: Arc<str>,
operations: HashMap<clock::Local, Operation>,
undo_stack: Vec<HistoryEntry>,
redo_stack: Vec<HistoryEntry>,
@ -539,7 +539,8 @@ pub struct UndoOperation {
}
impl Buffer {
pub fn new(replica_id: u16, remote_id: u64, history: History) -> Buffer {
pub fn new(replica_id: u16, remote_id: u64, base_text: String) -> Buffer {
let history = History::new(base_text.into());
let mut fragments = SumTree::new();
let mut insertions = SumTree::new();