Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add `git: open modified files` action (#32347)
Gabe Shahbazianc13be165cd8a
diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.jsonindex b85b0626b3e..62b120efabf 100644--- a/assets/keymaps/default-linux.json+++ b/assets/keymaps/default-linux.json@@ -115,6 +115,7 @@"ctrl-\"": "editor::ExpandAllDiffHunks","ctrl-i": "editor::ShowSignatureHelp","alt-g b": "git::Blame",+ "alt-g m": "git::OpenModifiedFiles","menu": "editor::OpenContextMenu","shift-f10": "editor::OpenContextMenu","ctrl-shift-e": "editor::ToggleEditPrediction",diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.jsonindex 225cddf5908..73497455879 100644--- a/assets/keymaps/default-macos.json+++ b/assets/keymaps/default-macos.json@@ -139,6 +139,7 @@"cmd-'": "editor::ToggleSelectedDiffHunks","cmd-\"": "editor::ExpandAllDiffHunks","cmd-alt-g b": "git::Blame",+ "cmd-alt-g m": "git::OpenModifiedFiles","cmd-i": "editor::ShowSignatureHelp","f9": "editor::ToggleBreakpoint","shift-f9": "editor::EditLogBreakpoint",diff --git a/crates/git/src/git.rs b/crates/git/src/git.rsindex fb7bca2144a..e2c6e549936 100644--- a/crates/git/src/git.rs+++ b/crates/git/src/git.rs@@ -57,6 +57,7 @@ actions!(ExpandCommitEditor,GenerateCommitMessage,Init,+ OpenModifiedFiles,]);diff --git a/crates/git_ui/src/git_ui.rs b/crates/git_ui/src/git_ui.rsindex 24291457205..d0c6792ceb7 100644--- a/crates/git_ui/src/git_ui.rs+++ b/crates/git_ui/src/git_ui.rs@@ -10,7 +10,7 @@ use git::{status::{FileStatus, StatusCode, UnmergedStatus, UnmergedStatusCode},};use git_panel_settings::GitPanelSettings;-use gpui::{Action, App, FocusHandle, actions};+use gpui::{Action, App, Context, FocusHandle, Window, actions};use onboarding::GitOnboardingModal;use project_diff::ProjectDiff;use ui::prelude::*;@@ -142,10 +142,41 @@ pub fn init(cx: &mut App) {panel.git_init(window, cx);});});+ workspace.register_action(|workspace, _: &git::OpenModifiedFiles, window, cx| {+ open_modified_files(workspace, window, cx);+ });}).detach();}+fn open_modified_files(+ workspace: &mut Workspace,+ window: &mut Window,+ cx: &mut Context<Workspace>,+) {+ let Some(panel) = workspace.panel::<git_panel::GitPanel>(cx) else {+ return;+ };+ let modified_paths: Vec<_> = panel.update(cx, |panel, cx| {+ let Some(repo) = panel.active_repository.as_ref() else {+ return Vec::new();+ };+ let repo = repo.read(cx);+ repo.cached_status()+ .filter_map(|entry| {+ if entry.status.is_modified() {+ repo.repo_path_to_project_path(&entry.repo_path, cx)+ } else {+ None+ }+ })+ .collect()+ });+ for path in modified_paths {+ workspace.open_path(path, None, true, window, cx).detach();+ }+}+pub fn git_status_icon(status: FileStatus) -> impl IntoElement {GitStatusIcon::new(status)}