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:
Cole Miller 2025-02-06 18:52:32 -05:00 committed by GitHub
parent ffcad71bfa
commit 73c487c222
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 922 additions and 875 deletions

26
Cargo.lock generated
View file

@ -2753,6 +2753,7 @@ dependencies = [
"ctor",
"dashmap 6.1.0",
"derive_more",
"diff 0.1.0",
"editor",
"env_logger 0.11.6",
"envy",
@ -3837,6 +3838,24 @@ dependencies = [
"zeroize",
]
[[package]]
name = "diff"
version = "0.1.0"
dependencies = [
"futures 0.3.31",
"git2",
"gpui",
"language",
"log",
"pretty_assertions",
"rope",
"serde_json",
"sum_tree",
"text",
"unindent",
"util",
]
[[package]]
name = "diff"
version = "0.1.13"
@ -4007,6 +4026,7 @@ dependencies = [
"convert_case 0.7.1",
"ctor",
"db",
"diff 0.1.0",
"emojis",
"env_logger 0.11.6",
"file_icons",
@ -5306,6 +5326,7 @@ dependencies = [
"anyhow",
"collections",
"db",
"diff 0.1.0",
"editor",
"feature_flags",
"futures 0.3.31",
@ -7910,9 +7931,9 @@ dependencies = [
"clock",
"collections",
"ctor",
"diff 0.1.0",
"env_logger 0.11.6",
"futures 0.3.31",
"git",
"gpui",
"indoc",
"itertools 0.14.0",
@ -9919,7 +9940,7 @@ version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d"
dependencies = [
"diff",
"diff 0.1.13",
"yansi",
]
@ -10015,6 +10036,7 @@ dependencies = [
"client",
"clock",
"collections",
"diff 0.1.0",
"env_logger 0.11.6",
"fancy-regex 0.14.0",
"fs",