From 58c49f1c43d43078c53c95adf2e1663578eed26b Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Wed, 28 Jan 2026 12:25:38 -0500 Subject: [PATCH] git: Hide toggle split diff button behind flag (cherry-pick #47878) (#47884) Release Notes: - N/A Co-authored-by: Jakub Konka --- 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(-) diff --git a/Cargo.lock b/Cargo.lock index 0ad2709c786c00d86ac568b8d0d31b9c4fe10af5..e5c859b24d343d4aae31271146f1d40743bacafd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7251,6 +7251,7 @@ dependencies = [ "ctor", "db", "editor", + "feature_flags", "futures 0.3.31", "fuzzy", "git", diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 6b691af3577ed49f677b7d1cc4c57db540c2718b..e4b3d1a6bb37f0080ba470c575fca2f82e8a6e31 100644 --- a/crates/editor/src/editor.rs +++ b/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; diff --git a/crates/editor/src/split.rs b/crates/editor/src/split.rs index a0d7251d6bbfdf1886fbddfa04a4771f1536aed8..1a8a6c626967321e910ca7ac4876c8dac0ceb2db 100644 --- a/crates/editor/src/split.rs +++ b/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"; diff --git a/crates/git_ui/Cargo.toml b/crates/git_ui/Cargo.toml index 504a168c5df42e7a9185d7de9c14012bfc65a08a..ae364fa55928f83f442ac700a6f4a22aece83724 100644 --- a/crates/git_ui/Cargo.toml +++ b/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 diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rs index 1b52202b47dc324334ab96c03c305392121ec12b..6e221589af292d1593ee5d2110620976c2312a30 100644 --- a/crates/git_ui/src/project_diff.rs +++ b/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::() { + 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(