Merge pull request #661 from zed-industries/follow
Introduce basic following experience
This commit is contained in:
commit
004f98cc6d
35 changed files with 3061 additions and 510 deletions
|
@ -142,7 +142,7 @@ pub enum Operation {
|
|||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Event {
|
||||
Operation(Operation),
|
||||
Edited,
|
||||
Edited { local: bool },
|
||||
Dirtied,
|
||||
Saved,
|
||||
FileHandleChanged,
|
||||
|
@ -967,7 +967,7 @@ impl Buffer {
|
|||
) -> Option<TransactionId> {
|
||||
if let Some((transaction_id, start_version)) = self.text.end_transaction_at(now) {
|
||||
let was_dirty = start_version != self.saved_version;
|
||||
self.did_edit(&start_version, was_dirty, cx);
|
||||
self.did_edit(&start_version, was_dirty, true, cx);
|
||||
Some(transaction_id)
|
||||
} else {
|
||||
None
|
||||
|
@ -1160,6 +1160,7 @@ impl Buffer {
|
|||
&mut self,
|
||||
old_version: &clock::Global,
|
||||
was_dirty: bool,
|
||||
local: bool,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) {
|
||||
if self.edits_since::<usize>(old_version).next().is_none() {
|
||||
|
@ -1168,7 +1169,7 @@ impl Buffer {
|
|||
|
||||
self.reparse(cx);
|
||||
|
||||
cx.emit(Event::Edited);
|
||||
cx.emit(Event::Edited { local });
|
||||
if !was_dirty {
|
||||
cx.emit(Event::Dirtied);
|
||||
}
|
||||
|
@ -1205,7 +1206,7 @@ impl Buffer {
|
|||
self.text.apply_ops(buffer_ops)?;
|
||||
self.deferred_ops.insert(deferred_ops);
|
||||
self.flush_deferred_ops(cx);
|
||||
self.did_edit(&old_version, was_dirty, cx);
|
||||
self.did_edit(&old_version, was_dirty, false, cx);
|
||||
// Notify independently of whether the buffer was edited as the operations could include a
|
||||
// selection update.
|
||||
cx.notify();
|
||||
|
@ -1320,7 +1321,7 @@ impl Buffer {
|
|||
|
||||
if let Some((transaction_id, operation)) = self.text.undo() {
|
||||
self.send_operation(Operation::Buffer(operation), cx);
|
||||
self.did_edit(&old_version, was_dirty, cx);
|
||||
self.did_edit(&old_version, was_dirty, true, cx);
|
||||
Some(transaction_id)
|
||||
} else {
|
||||
None
|
||||
|
@ -1341,7 +1342,7 @@ impl Buffer {
|
|||
self.send_operation(Operation::Buffer(operation), cx);
|
||||
}
|
||||
if undone {
|
||||
self.did_edit(&old_version, was_dirty, cx)
|
||||
self.did_edit(&old_version, was_dirty, true, cx)
|
||||
}
|
||||
undone
|
||||
}
|
||||
|
@ -1352,7 +1353,7 @@ impl Buffer {
|
|||
|
||||
if let Some((transaction_id, operation)) = self.text.redo() {
|
||||
self.send_operation(Operation::Buffer(operation), cx);
|
||||
self.did_edit(&old_version, was_dirty, cx);
|
||||
self.did_edit(&old_version, was_dirty, true, cx);
|
||||
Some(transaction_id)
|
||||
} else {
|
||||
None
|
||||
|
@ -1373,7 +1374,7 @@ impl Buffer {
|
|||
self.send_operation(Operation::Buffer(operation), cx);
|
||||
}
|
||||
if redone {
|
||||
self.did_edit(&old_version, was_dirty, cx)
|
||||
self.did_edit(&old_version, was_dirty, true, cx)
|
||||
}
|
||||
redone
|
||||
}
|
||||
|
@ -1439,7 +1440,7 @@ impl Buffer {
|
|||
if !ops.is_empty() {
|
||||
for op in ops {
|
||||
self.send_operation(Operation::Buffer(op), cx);
|
||||
self.did_edit(&old_version, was_dirty, cx);
|
||||
self.did_edit(&old_version, was_dirty, true, cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1800,12 +1801,6 @@ impl BufferSnapshot {
|
|||
.min_by_key(|(open_range, close_range)| close_range.end - open_range.start)
|
||||
}
|
||||
|
||||
/*
|
||||
impl BufferSnapshot
|
||||
pub fn remote_selections_in_range(&self, Range<Anchor>) -> impl Iterator<Item = (ReplicaId, impl Iterator<Item = &Selection<Anchor>>)>
|
||||
pub fn remote_selections_in_range(&self, Range<Anchor>) -> impl Iterator<Item = (ReplicaId, i
|
||||
*/
|
||||
|
||||
pub fn remote_selections_in_range<'a>(
|
||||
&'a self,
|
||||
range: Range<Anchor>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue