mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-04 05:53:21 +01:00
git: Move diff hunk operations onto buffer diffs (#63556)
# Objective Keep Git-specific diff-base knowledge in `GitStore`, where Git operations are defined. Related to FR-135. ## Solution Give each `BufferDiff` its supported hunk operations. Keep editor hooks limited to rendering custom controls. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - N/A
This commit is contained in:
1 parent
c4bc69e576
commit
229450844d
21 files changed
+501
-603
No files matched your search
@@ -2,7 +2,7 @@ use anyhow::{Context as _, Result};
|
||||
use buffer_diff::BufferDiff;
|
||||
use collections::HashMap;
|
||||
use editor::{
|
||||
Addon, Editor, EditorEvent, EditorSettings, MultiBuffer, RestoreOnlyDiffHunkDelegate,
|
||||
Addon, Editor, EditorEvent, EditorSettings, HiddenDiffHunkRenderer, MultiBuffer,
|
||||
SplittableEditor, hover_markdown_style, multibuffer_context_lines,
|
||||
};
|
||||
use futures_lite::future::yield_now;
|
||||
@@ -326,7 +326,7 @@ impl CommitView {
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
editor.set_diff_hunk_delegate(Some(Arc::new(RestoreOnlyDiffHunkDelegate)), cx);
|
||||
editor.set_diff_hunk_renderer(Some(Arc::new(HiddenDiffHunkRenderer)), cx);
|
||||
|
||||
editor.rhs_editor().update(cx, |editor, cx| {
|
||||
editor.set_show_bookmarks(false, cx);
|
||||
@@ -417,7 +417,6 @@ impl CommitView {
|
||||
&snapshot,
|
||||
snapshot.language().cloned(),
|
||||
Some(language_registry.clone()),
|
||||
buffer_diff::DiffBaseKind::Oid,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
@@ -1159,15 +1158,8 @@ async fn build_buffer_diff(
|
||||
let language = cx.update(|_, cx| buffer.read(cx).language().cloned())?;
|
||||
let buffer = cx.update(|_, cx| buffer.read(cx).snapshot())?;
|
||||
|
||||
let diff = cx.new(|cx| {
|
||||
BufferDiff::new(
|
||||
&buffer.text,
|
||||
language,
|
||||
Some(language_registry.clone()),
|
||||
buffer_diff::DiffBaseKind::Oid,
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let diff =
|
||||
cx.new(|cx| BufferDiff::new(&buffer.text, language, Some(language_registry.clone()), cx));
|
||||
|
||||
diff.update(cx, |diff, cx| {
|
||||
diff.set_base_text(
|
||||
@@ -1346,7 +1338,7 @@ impl Item for CommitView {
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
editor.set_diff_hunk_delegate(Some(Arc::new(RestoreOnlyDiffHunkDelegate)), cx);
|
||||
editor.set_diff_hunk_renderer(Some(Arc::new(HiddenDiffHunkRenderer)), cx);
|
||||
editor.rhs_editor().update(cx, |editor, cx| {
|
||||
editor.set_show_bookmarks(false, cx);
|
||||
editor.set_show_breakpoints(false, cx);
|
||||
|
||||
Reference in new issue
Block a user