Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions assets/settings/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
15 changes: 1 addition & 14 deletions crates/editor/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 6 additions & 1 deletion crates/git_ui/src/project_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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);
Expand Down
1 change: 0 additions & 1 deletion crates/search/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ any_vec.workspace = true
bitflags.workspace = true
collections.workspace = true
editor.workspace = true
feature_flags.workspace = true
fs.workspace = true
futures.workspace = true
gpui.workspace = true
Expand Down
7 changes: 2 additions & 5 deletions crates/search/src/buffer_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _,
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions crates/settings_content/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub struct EditorSettingsContent {

/// How to display diffs in the editor.
///
/// Default: unified
/// Default: split
pub diff_view_style: Option<DiffViewStyle>,
}

Expand Down Expand Up @@ -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,
}

Expand Down
15 changes: 14 additions & 1 deletion crates/settings_ui/src/page_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ fn editor_page() -> SettingsPage {
]
}

fn multibuffer_section() -> [SettingsPageItem; 5] {
fn multibuffer_section() -> [SettingsPageItem; 6] {
[
SettingsPageItem::SectionHeader("Multibuffer"),
SettingsPageItem::SettingItem(SettingItem {
Expand Down Expand Up @@ -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,
}),
]
}

Expand Down
1 change: 1 addition & 0 deletions crates/settings_ui/src/settings_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down