Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
git: Enable the split diff for everyone (#48912)
Cole Millerf7314976bdeb
diff --git a/Cargo.lock b/Cargo.lockindex 310fd83a406..720dadc0225 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -14867,7 +14867,6 @@ dependencies = ["client","collections","editor",- "feature_flags","fs","futures 0.3.31","gpui",diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex 838d6c3f85d..e1d38e08b72 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -293,8 +293,8 @@"completion_detail_alignment": "left",// How to display diffs in the editor.//- // Default: unified- "diff_view_style": "unified",+ // Default: split+ "diff_view_style": "split",// Show method signatures in the editor, when inside parentheses."auto_signature_help": false,// Whether to show the signature help after completion or a bracket pair inserted.diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 4cdd03463da..bf241d01d19 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -78,7 +78,7 @@ pub use multi_buffer::{MultiBufferOffset, MultiBufferOffsetUtf16, MultiBufferSnapshot, PathKey, RowInfo, ToOffset,ToPoint,};-pub use split::{SplitDiffFeatureFlag, SplittableEditor, ToggleSplitDiff};+pub use split::{SplittableEditor, ToggleSplitDiff};pub use split_editor_view::SplitEditorView;pub use text::Bias;diff --git a/crates/editor/src/split.rs b/crates/editor/src/split.rsindex 1e1d6785bbf..b3b3c20ae9a 100644--- a/crates/editor/src/split.rs+++ b/crates/editor/src/split.rs@@ -5,7 +5,7 @@ use std::{use buffer_diff::{BufferDiff, BufferDiffSnapshot};use collections::HashMap;-use feature_flags::{FeatureFlag, FeatureFlagAppExt as _};+use gpui::{Action, AppContext as _, Entity, EventEmitter, Focusable, Subscription, WeakEntity};use itertools::Itertools;use language::{Buffer, Capability};@@ -362,16 +362,6 @@ fn patch_for_excerpt(}}-pub struct SplitDiffFeatureFlag;--impl FeatureFlag for SplitDiffFeatureFlag {- const NAME: &'static str = "split-diff";-- fn enabled_for_staff() -> bool {- true- }-}-#[derive(Clone, Copy, PartialEq, Eq, Action, Default)]#[action(namespace = editor)]pub struct ToggleSplitDiff;@@ -513,9 +503,6 @@ impl SplittableEditor {}pub fn split(&mut self, window: &mut Window, cx: &mut Context<Self>) {- if !cx.has_flag::<SplitDiffFeatureFlag>() {- return;- }if self.lhs.is_some() {return;}diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rsindex f64931491d9..21a0d41fe09 100644--- a/crates/git_ui/src/project_diff.rs+++ b/crates/git_ui/src/project_diff.rs@@ -1843,7 +1843,7 @@ mod tests {use gpui::TestAppContext;use project::FakeFs;use serde_json::json;- use settings::SettingsStore;+ use settings::{DiffViewStyle, SettingsStore};use std::path::Path;use unindent::Unindent as _;use util::{@@ -1862,6 +1862,11 @@ mod tests {cx.update(|cx| {let store = SettingsStore::test(cx);cx.set_global(store);+ cx.update_global::<SettingsStore, _>(|store, cx| {+ store.update_user_settings(cx, |settings| {+ settings.editor.diff_view_style = Some(DiffViewStyle::Unified);+ });+ });theme::init(theme::LoadThemes::JustBase, cx);editor::init(cx);crate::init(cx);diff --git a/crates/search/Cargo.toml b/crates/search/Cargo.tomlindex c9abbe1ee82..9613bd72091 100644--- a/crates/search/Cargo.toml+++ b/crates/search/Cargo.toml@@ -26,7 +26,6 @@ any_vec.workspace = truebitflags.workspace = truecollections.workspace = trueeditor.workspace = true-feature_flags.workspace = truefs.workspace = truefutures.workspace = truegpui.workspace = truediff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rsindex 1d46938d6aa..25cbb4ef4cd 100644--- a/crates/search/src/buffer_search.rs+++ b/crates/search/src/buffer_search.rs@@ -13,11 +13,9 @@ use crate::{use any_vec::AnyVec;use collections::HashMap;use editor::{- DisplayPoint, Editor, EditorSettings, MultiBufferOffset, SplitDiffFeatureFlag,- SplittableEditor, ToggleSplitDiff,+ DisplayPoint, Editor, EditorSettings, MultiBufferOffset, SplittableEditor, ToggleSplitDiff,actions::{Backtab, FoldAll, Tab, ToggleFoldAll, UnfoldAll},};-use feature_flags::FeatureFlagAppExt as _;use futures::channel::oneshot;use gpui::{Action, App, ClickEvent, Context, Entity, EventEmitter, Focusable, InteractiveElement as _,@@ -107,8 +105,7 @@ impl Render for BufferSearchBar {fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {let focus_handle = self.focus_handle(cx);- let has_splittable_editor =- self.splittable_editor.is_some() && cx.has_flag::<SplitDiffFeatureFlag>();+ let has_splittable_editor = self.splittable_editor.is_some();let split_buttons = if has_splittable_editor {self.splittable_editor.as_ref()diff --git a/crates/settings_content/src/editor.rs b/crates/settings_content/src/editor.rsindex f07e41e0e52..4d824e85e0e 100644--- a/crates/settings_content/src/editor.rs+++ b/crates/settings_content/src/editor.rs@@ -224,7 +224,7 @@ pub struct EditorSettingsContent {/// How to display diffs in the editor.///- /// Default: unified+ /// Default: splitpub diff_view_style: Option<DiffViewStyle>,}@@ -806,9 +806,9 @@ pub enum SnippetSortOrder {#[serde(rename_all = "snake_case")]pub enum DiffViewStyle {/// Show diffs in a single unified view.- #[default]Unified,/// Show diffs in a split view.+ #[default]Split,}diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rsindex 19b76040611..0d2836ff8b7 100644--- a/crates/settings_ui/src/page_data.rs+++ b/crates/settings_ui/src/page_data.rs@@ -1466,7 +1466,7 @@ fn editor_page() -> SettingsPage {]}- fn multibuffer_section() -> [SettingsPageItem; 5] {+ fn multibuffer_section() -> [SettingsPageItem; 6] {[SettingsPageItem::SectionHeader("Multibuffer"),SettingsPageItem::SettingItem(SettingItem {@@ -1533,6 +1533,19 @@ fn editor_page() -> SettingsPage {metadata: None,files: USER,}),+ SettingsPageItem::SettingItem(SettingItem {+ title: "Diff View Style",+ description: "How to display diffs in the editor.",+ field: Box::new(SettingField {+ json_path: Some("diff_view_style"),+ pick: |settings_content| settings_content.editor.diff_view_style.as_ref(),+ write: |settings_content, value| {+ settings_content.editor.diff_view_style = value;+ },+ }),+ metadata: None,+ files: USER,+ }),]}diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rsindex 8f8ddcab3bd..f1eb9177855 100644--- a/crates/settings_ui/src/settings_ui.rs+++ b/crates/settings_ui/src/settings_ui.rs@@ -487,6 +487,7 @@ fn init_renderers(cx: &mut App) {.add_basic_renderer::<settings::WordsCompletionMode>(render_dropdown).add_basic_renderer::<settings::LspInsertMode>(render_dropdown).add_basic_renderer::<settings::CompletionDetailAlignment>(render_dropdown)+ .add_basic_renderer::<settings::DiffViewStyle>(render_dropdown).add_basic_renderer::<settings::AlternateScroll>(render_dropdown).add_basic_renderer::<settings::TerminalBlink>(render_dropdown).add_basic_renderer::<settings::CursorShapeContent>(render_dropdown)