Add editor::RevertSelectedHunks to revert git diff hunks in the editor (#9068)

https://github.com/zed-industries/zed/assets/2690773/653b5658-e3f3-4aee-9a9d-0f2153b4141b

Release Notes:

- Added `editor::RevertSelectedHunks` (`cmd-alt-z` by default) for
reverting git hunks from the editor
This commit is contained in:
Kirill Bulatov 2024-03-09 01:37:24 +02:00 committed by GitHub
parent 6a7a3b257a
commit 347178039c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 1003 additions and 72 deletions

View file

@ -930,8 +930,17 @@ impl Buffer {
/// against the buffer text.
pub fn set_diff_base(&mut self, diff_base: Option<String>, cx: &mut ModelContext<Self>) {
self.diff_base = diff_base;
self.git_diff_recalc(cx);
cx.emit(Event::DiffBaseChanged);
if let Some(recalc_task) = self.git_diff_recalc(cx) {
cx.spawn(|buffer, mut cx| async move {
recalc_task.await;
buffer
.update(&mut cx, |_, cx| {
cx.emit(Event::DiffBaseChanged);
})
.ok();
})
.detach();
}
}
/// Recomputes the Git diff status.