mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 10:29:35 +03:00
Store history base text as rope
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
parent
f51425d390
commit
7e06062bdb
@ -90,8 +90,7 @@ impl HistoryEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct History {
|
struct History {
|
||||||
// TODO: Turn this into a String or Rope, maybe.
|
base_text: Rope,
|
||||||
base_text: Arc<str>,
|
|
||||||
operations: TreeMap<clock::Local, Operation>,
|
operations: TreeMap<clock::Local, Operation>,
|
||||||
insertion_slices: HashMap<clock::Local, Vec<InsertionSlice>>,
|
insertion_slices: HashMap<clock::Local, Vec<InsertionSlice>>,
|
||||||
undo_stack: Vec<HistoryEntry>,
|
undo_stack: Vec<HistoryEntry>,
|
||||||
@ -107,7 +106,7 @@ struct InsertionSlice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl History {
|
impl History {
|
||||||
pub fn new(base_text: Arc<str>) -> Self {
|
pub fn new(base_text: Rope) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base_text,
|
base_text,
|
||||||
operations: Default::default(),
|
operations: Default::default(),
|
||||||
@ -470,7 +469,7 @@ impl Buffer {
|
|||||||
let line_ending = LineEnding::detect(&base_text);
|
let line_ending = LineEnding::detect(&base_text);
|
||||||
LineEnding::normalize(&mut base_text);
|
LineEnding::normalize(&mut base_text);
|
||||||
|
|
||||||
let history = History::new(base_text.into());
|
let history = History::new(Rope::from(base_text.as_ref()));
|
||||||
let mut fragments = SumTree::new();
|
let mut fragments = SumTree::new();
|
||||||
let mut insertions = SumTree::new();
|
let mut insertions = SumTree::new();
|
||||||
|
|
||||||
@ -478,7 +477,7 @@ impl Buffer {
|
|||||||
let mut lamport_clock = clock::Lamport::new(replica_id);
|
let mut lamport_clock = clock::Lamport::new(replica_id);
|
||||||
let mut version = clock::Global::new();
|
let mut version = clock::Global::new();
|
||||||
|
|
||||||
let visible_text = Rope::from(history.base_text.as_ref());
|
let visible_text = history.base_text.clone();
|
||||||
if !visible_text.is_empty() {
|
if !visible_text.is_empty() {
|
||||||
let insertion_timestamp = InsertionTimestamp {
|
let insertion_timestamp = InsertionTimestamp {
|
||||||
replica_id: 0,
|
replica_id: 0,
|
||||||
@ -1165,7 +1164,7 @@ impl Buffer {
|
|||||||
self.history.group_until(transaction_id);
|
self.history.group_until(transaction_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn base_text(&self) -> &Arc<str> {
|
pub fn base_text(&self) -> &Rope {
|
||||||
&self.history.base_text
|
&self.history.base_text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user