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: Hide toggle split diff button behind feature flag (#47878)

Cole Millera21e21c15c13
diff --git a/Cargo.lock b/Cargo.lock
index 01891d3bf87..43186533548 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 6b691af3577..e4b3d1a6bb3 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 a0d7251d6bb..1a8a6c62696 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 504a168c5df..ae364fa5592 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 1b52202b47d..6e221589af2 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::<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(