Introduce diff crate to unite BufferDiff and BufferChangeSet (#24392)
This is a refactoring PR that does three things: - First, it introduces a new `diff` crate that holds the previous contents of the `git::diff` module, plus the `BufferChangeSet` type formerly of `project::buffer_store`. The new crate is necessary since simply moving `BufferChangeSet` into `git::diff` results in a dependency cycle due to the use of `language::Buffer` to represent the diff base in `BufferChangeSet`. - Second, it renames the two main types in the new diff crate: `BufferDiff` becomes `BufferDiffSnapshot`, and `BufferChangeSet` becomes `BufferDiff`. This reflects that the relationship between these two types (immutable cheaply-cloneable "value" type + stateful "resource type" with subscriptions) mirrors existing pairs like `Buffer`/`BufferSnapshot`. References to "change sets" throughout the codebase are updated to refer to "diffs" instead. - Finally, it moves the base_text field of the new BufferDiff type to BufferDiffSnapshot. Release Notes: - N/A --------- Co-authored-by: maxbrunsfeld <max@zed.dev>
This commit is contained in:
parent
ffcad71bfa
commit
73c487c222
31 changed files with 922 additions and 875 deletions
|
@ -21,6 +21,7 @@ mod project_tests;
|
|||
|
||||
mod direnv;
|
||||
mod environment;
|
||||
use diff::BufferDiff;
|
||||
pub use environment::EnvironmentErrorMessage;
|
||||
use git::Repository;
|
||||
pub mod search_history;
|
||||
|
@ -28,7 +29,7 @@ mod yarn;
|
|||
|
||||
use crate::git::GitState;
|
||||
use anyhow::{anyhow, Context as _, Result};
|
||||
use buffer_store::{BufferChangeSet, BufferStore, BufferStoreEvent};
|
||||
use buffer_store::{BufferStore, BufferStoreEvent};
|
||||
use client::{
|
||||
proto, Client, Collaborator, PendingEntitySubscription, ProjectId, TypedEnvelope, UserStore,
|
||||
};
|
||||
|
@ -1955,31 +1956,31 @@ impl Project {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn open_unstaged_changes(
|
||||
pub fn open_unstaged_diff(
|
||||
&mut self,
|
||||
buffer: Entity<Buffer>,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<Entity<BufferChangeSet>>> {
|
||||
) -> Task<Result<Entity<BufferDiff>>> {
|
||||
if self.is_disconnected(cx) {
|
||||
return Task::ready(Err(anyhow!(ErrorCode::Disconnected)));
|
||||
}
|
||||
|
||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
||||
buffer_store.open_unstaged_changes(buffer, cx)
|
||||
buffer_store.open_unstaged_diff(buffer, cx)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn open_uncommitted_changes(
|
||||
pub fn open_uncommitted_diff(
|
||||
&mut self,
|
||||
buffer: Entity<Buffer>,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<Entity<BufferChangeSet>>> {
|
||||
) -> Task<Result<Entity<BufferDiff>>> {
|
||||
if self.is_disconnected(cx) {
|
||||
return Task::ready(Err(anyhow!(ErrorCode::Disconnected)));
|
||||
}
|
||||
|
||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
||||
buffer_store.open_uncommitted_changes(buffer, cx)
|
||||
buffer_store.open_uncommitted_diff(buffer, cx)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue