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

View file

@ -304,8 +304,8 @@ message Envelope {
SyncExtensionsResponse sync_extensions_response = 286;
InstallExtension install_extension = 287;
OpenUnstagedChanges open_unstaged_changes = 288;
OpenUnstagedChangesResponse open_unstaged_changes_response = 289;
OpenUnstagedDiff open_unstaged_diff = 288;
OpenUnstagedDiffResponse open_unstaged_diff_response = 289;
RegisterBufferWithLanguageServers register_buffer_with_language_servers = 290;
@ -314,8 +314,8 @@ message Envelope {
Commit commit = 295;
OpenCommitMessageBuffer open_commit_message_buffer = 296;
OpenUncommittedChanges open_uncommitted_changes = 297;
OpenUncommittedChangesResponse open_uncommitted_changes_response = 298; // current max
OpenUncommittedDiff open_uncommitted_diff = 297;
OpenUncommittedDiffResponse open_uncommitted_diff_response = 298; // current max
}
reserved 87 to 88;
@ -2062,21 +2062,21 @@ message UpdateDiffBases {
Mode mode = 5;
}
message OpenUnstagedChanges {
message OpenUnstagedDiff {
uint64 project_id = 1;
uint64 buffer_id = 2;
}
message OpenUnstagedChangesResponse {
message OpenUnstagedDiffResponse {
optional string staged_text = 1;
}
message OpenUncommittedChanges {
message OpenUncommittedDiff {
uint64 project_id = 1;
uint64 buffer_id = 2;
}
message OpenUncommittedChangesResponse {
message OpenUncommittedDiffResponse {
enum Mode {
INDEX_MATCHES_HEAD = 0;
INDEX_AND_HEAD = 1;

View file

@ -219,10 +219,10 @@ messages!(
(GetImplementationResponse, Background),
(GetLlmToken, Background),
(GetLlmTokenResponse, Background),
(OpenUnstagedChanges, Foreground),
(OpenUnstagedChangesResponse, Foreground),
(OpenUncommittedChanges, Foreground),
(OpenUncommittedChangesResponse, Foreground),
(OpenUnstagedDiff, Foreground),
(OpenUnstagedDiffResponse, Foreground),
(OpenUncommittedDiff, Foreground),
(OpenUncommittedDiffResponse, Foreground),
(GetUsers, Foreground),
(Hello, Foreground),
(IncomingCall, Foreground),
@ -424,8 +424,8 @@ request_messages!(
(GetProjectSymbols, GetProjectSymbolsResponse),
(GetReferences, GetReferencesResponse),
(GetSignatureHelp, GetSignatureHelpResponse),
(OpenUnstagedChanges, OpenUnstagedChangesResponse),
(OpenUncommittedChanges, OpenUncommittedChangesResponse),
(OpenUnstagedDiff, OpenUnstagedDiffResponse),
(OpenUncommittedDiff, OpenUncommittedDiffResponse),
(GetSupermavenApiKey, GetSupermavenApiKeyResponse),
(GetTypeDefinition, GetTypeDefinitionResponse),
(LinkedEditingRange, LinkedEditingRangeResponse),
@ -546,8 +546,8 @@ entity_messages!(
GetProjectSymbols,
GetReferences,
GetSignatureHelp,
OpenUnstagedChanges,
OpenUncommittedChanges,
OpenUnstagedDiff,
OpenUncommittedDiff,
GetTypeDefinition,
InlayHints,
JoinProject,