mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
git: Enable the split diff for everyone (#48912)
Release Notes:
- Added support for viewing diffs in split ("side by side") mode
This commit is contained in:
parent
05e99dad54
commit
f7314976bd
10 changed files with 29 additions and 28 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -14867,7 +14867,6 @@ dependencies = [
|
|||
"client",
|
||||
"collections",
|
||||
"editor",
|
||||
"feature_flags",
|
||||
"fs",
|
||||
"futures 0.3.31",
|
||||
"gpui",
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ pub struct EditorSettingsContent {
|
|||
|
||||
/// How to display diffs in the editor.
|
||||
///
|
||||
/// Default: unified
|
||||
/// Default: split
|
||||
pub 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,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue