git: Hide toggle split diff button behind flag (cherry-pick #47878) (#47884)

Cole Miller and Jakub Konka created

Release Notes:

- N/A

Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>

Change summary

Cargo.lock                        |  1 
crates/editor/src/editor.rs       |  2 
crates/editor/src/split.rs        |  2 
crates/git_ui/Cargo.toml          |  1 
crates/git_ui/src/project_diff.rs | 45 +++++++++++++++++++-------------
5 files changed, 31 insertions(+), 20 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -7251,6 +7251,7 @@ dependencies = [
  "ctor",
  "db",
  "editor",
+ "feature_flags",
  "futures 0.3.31",
  "fuzzy",
  "git",

crates/editor/src/editor.rs 🔗

@@ -72,7 +72,7 @@ pub use multi_buffer::{
     MultiBufferOffset, MultiBufferOffsetUtf16, MultiBufferSnapshot, PathKey, RowInfo, ToOffset,
     ToPoint,
 };
-pub use split::{SplittableEditor, ToggleLockedCursors, ToggleSplitDiff};
+pub use split::{SplitDiffFeatureFlag, SplittableEditor, ToggleLockedCursors, ToggleSplitDiff};
 pub use split_editor_view::SplitEditorView;
 pub use text::Bias;
 

crates/editor/src/split.rs 🔗

@@ -237,7 +237,7 @@ where
     })
 }
 
-struct SplitDiffFeatureFlag;
+pub struct SplitDiffFeatureFlag;
 
 impl FeatureFlag for SplitDiffFeatureFlag {
     const NAME: &'static str = "split-diff";

crates/git_ui/Cargo.toml 🔗

@@ -27,6 +27,7 @@ command_palette_hooks.workspace = true
 component.workspace = true
 db.workspace = true
 editor.workspace = true
+feature_flags.workspace = true
 futures.workspace = true
 fuzzy.workspace = true
 git.workspace = true

crates/git_ui/src/project_diff.rs 🔗

@@ -8,11 +8,13 @@ use anyhow::{Context as _, Result, anyhow};
 use buffer_diff::{BufferDiff, DiffHunkSecondaryStatus};
 use collections::{HashMap, HashSet};
 use editor::{
-    Addon, Editor, EditorEvent, SelectionEffects, SplittableEditor, ToggleSplitDiff,
+    Addon, Editor, EditorEvent, SelectionEffects, SplitDiffFeatureFlag, SplittableEditor,
+    ToggleSplitDiff,
     actions::{GoToHunk, GoToPreviousHunk, SendReviewToAgent},
     multibuffer_context_lines,
     scroll::Autoscroll,
 };
+use feature_flags::FeatureFlagAppExt as _;
 use git::{
     Commit, StageAll, StageAndNext, ToggleStaged, UnstageAll, UnstageAndNext,
     repository::{Branch, RepoPath, Upstream, UpstreamTracking, UpstreamTrackingStatus},
@@ -1435,24 +1437,31 @@ impl Render for ProjectDiffToolbar {
                             )
                         },
                     )
-                    .child(
-                        Button::new(
-                            "toggle-split",
-                            if button_states.is_split {
-                                "Stacked View"
-                            } else {
-                                "Split View"
-                            },
+                    .map(|this| {
+                        if !cx.has_flag::<SplitDiffFeatureFlag>() {
+                            return this;
+                        }
+                        this.child(
+                            Button::new(
+                                "toggle-split",
+                                if button_states.is_split {
+                                    "Stacked View"
+                                } else {
+                                    "Split View"
+                                },
+                            )
+                            .tooltip(Tooltip::for_action_title_in(
+                                "Toggle Split View",
+                                &ToggleSplitDiff,
+                                &focus_handle,
+                            ))
+                            .on_click(cx.listener(
+                                |this, _, window, cx| {
+                                    this.dispatch_action(&ToggleSplitDiff, window, cx);
+                                },
+                            )),
                         )
-                        .tooltip(Tooltip::for_action_title_in(
-                            "Toggle Split View",
-                            &ToggleSplitDiff,
-                            &focus_handle,
-                        ))
-                        .on_click(cx.listener(|this, _, window, cx| {
-                            this.dispatch_action(&ToggleSplitDiff, window, cx);
-                        })),
-                    )
+                    })
                     .child(
                         Button::new("commit", "Commit")
                             .tooltip(Tooltip::for_action_title_in(