Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

git_ui: Reset the project diff at the start when it is deployed again (#43579)

Marco Mihai Condrache632bd378ba71
diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rs
index 3f689567327..4d7a27354b1 100644
--- a/crates/git_ui/src/project_diff.rs
+++ b/crates/git_ui/src/project_diff.rs
@@ -156,6 +156,10 @@ impl ProjectDiff {
.items_of_type::<Self>(cx)
.find(|item| matches!(item.read(cx).diff_base(cx), DiffBase::Head));
let project_diff = if let Some(existing) = existing {
+ existing.update(cx, |project_diff, cx| {
+ project_diff.move_to_beginning(window, cx);
+ });
+
workspace.activate_item(&existing, true, true, window, cx);
existing
} else {
@@ -365,6 +369,14 @@ impl ProjectDiff {
})
}
+ fn move_to_beginning(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+ self.editor.update(cx, |editor, cx| {
+ editor.primary_editor().update(cx, |editor, cx| {
+ editor.move_to_beginning(&Default::default(), window, cx);
+ });
+ });
+ }
+
fn move_to_path(&mut self, path_key: PathKey, window: &mut Window, cx: &mut Context<Self>) {
if let Some(position) = self.multibuffer.read(cx).location_for_path(&path_key, cx) {
self.editor.update(cx, |editor, cx| {