Implement staging and unstaging hunks (#24606)

- [x] Staging hunks
- [x] Unstaging hunks
- [x] Write a randomized test
- [x] Get test passing
- [x] Fix existing bug in diff_base_byte_range computation
- [x] Remote project support
- [ ] ~~Improve performance of
buffer_range_to_unchanged_diff_base_range~~
- [ ] ~~Bug: project diff editor scrolls to top when staging/unstaging
hunk~~ existing issue
- [ ] ~~UI~~ deferred
- [x] Tricky cases
  - [x] Correctly handle acting on multiple hunks for a single file
- [x] Remove path from index when unstaging the last staged hunk, if
it's absent from HEAD, or staging the only hunk, if it's deleted in the
working copy

Release Notes:

- Add `ToggleStagedSelectedDiffHunks` action for staging and unstaging
individual diff hunks
This commit is contained in:
Cole Miller 2025-02-12 14:46:42 -05:00 committed by GitHub
parent ea8da43c6b
commit eea6b526dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 768 additions and 70 deletions

View file

@ -315,7 +315,9 @@ message Envelope {
OpenCommitMessageBuffer open_commit_message_buffer = 296;
OpenUncommittedDiff open_uncommitted_diff = 297;
OpenUncommittedDiffResponse open_uncommitted_diff_response = 298; // current max
OpenUncommittedDiffResponse open_uncommitted_diff_response = 298;
SetIndexText set_index_text = 299; // current max
}
reserved 87 to 88;
@ -2087,6 +2089,14 @@ message OpenUncommittedDiffResponse {
Mode mode = 3;
}
message SetIndexText {
uint64 project_id = 1;
uint64 worktree_id = 2;
uint64 work_directory_id = 3;
string path = 4;
optional string text = 5;
}
message GetNotifications {
optional uint64 before_id = 1;
}

View file

@ -440,6 +440,7 @@ messages!(
(SyncExtensionsResponse, Background),
(InstallExtension, Background),
(RegisterBufferWithLanguageServers, Background),
(SetIndexText, Background),
);
request_messages!(
@ -573,6 +574,7 @@ request_messages!(
(SyncExtensions, SyncExtensionsResponse),
(InstallExtension, Ack),
(RegisterBufferWithLanguageServers, Ack),
(SetIndexText, Ack),
);
entity_messages!(
@ -665,6 +667,7 @@ entity_messages!(
GetPathMetadata,
CancelLanguageServerWork,
RegisterBufferWithLanguageServers,
SetIndexText,
);
entity_messages!(