Skip to content

Commit

Permalink
Revert useless changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeoneToIgnore committed May 1, 2024
1 parent 09ef08a commit b6d3e92
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 54 deletions.
15 changes: 0 additions & 15 deletions crates/editor/src/display_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,6 @@ pub(crate) struct Highlights<'a> {
pub struct HighlightStyles {
pub inlay_hint: Option<HighlightStyle>,
pub suggestion: Option<HighlightStyle>,
pub git_created: Option<HighlightStyle>,
pub git_modified: Option<HighlightStyle>,
pub git_deleted: Option<HighlightStyle>,
}

pub struct HighlightedChunk<'a> {
Expand Down Expand Up @@ -558,18 +555,6 @@ impl DisplaySnapshot {
HighlightStyles {
inlay_hint: Some(editor_style.inlay_hints_style),
suggestion: Some(editor_style.suggestions_style),
git_created: Some(HighlightStyle {
background_color: Some(editor_style.status.git().created),
..HighlightStyle::default()
}),
git_modified: Some(HighlightStyle {
background_color: Some(editor_style.status.git().modified),
..HighlightStyle::default()
}),
git_deleted: Some(HighlightStyle {
background_color: Some(editor_style.status.git().deleted),
..HighlightStyle::default()
}),
},
)
.map(|chunk| {
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 @@ -8729,7 +8729,7 @@ impl Editor {

pub fn fold_ranges<T: ToOffset + Clone>(
&mut self,
ranges: impl IntoIterator<Item = Range<T>> + Clone,
ranges: impl IntoIterator<Item = Range<T>>,
auto_scroll: bool,
cx: &mut ViewContext<Self>,
) {
Expand Down
8 changes: 6 additions & 2 deletions crates/editor/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,11 @@ impl EditorElement {
});
}

fn paint_diff_hunks(bounds: Bounds<Pixels>, layout: &EditorLayout, cx: &mut WindowContext) {
fn paint_diff_hunks(
gutter_bounds: Bounds<Pixels>,
layout: &EditorLayout,
cx: &mut WindowContext,
) {
if layout.display_hunks.is_empty() {
return;
}
Expand All @@ -2367,7 +2371,7 @@ impl EditorElement {
let hunk_bounds = Self::diff_hunk_bounds(
&layout.position_map.snapshot,
line_height,
bounds,
gutter_bounds,
&hunk,
);
Some((
Expand Down
9 changes: 2 additions & 7 deletions crates/editor/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::ops::Range;
use git::diff::{DiffHunk, DiffHunkStatus};
use language::Point;
use multi_buffer::Anchor;
use text::Bias;

use crate::{
display_map::{DisplaySnapshot, ToDisplayPoint},
Expand Down Expand Up @@ -86,12 +85,8 @@ pub fn diff_hunk_to_display(hunk: &DiffHunk<u32>, snapshot: &DisplaySnapshot) ->
let hunk_end_row = hunk.associated_range.end.max(hunk.associated_range.start);
let hunk_end_point = Point::new(hunk_end_row, 0);

let multi_buffer_start = snapshot
.buffer_snapshot
.anchor_at(hunk_start_point, Bias::Right);
let multi_buffer_end = snapshot
.buffer_snapshot
.anchor_at(hunk_end_point, Bias::Left);
let multi_buffer_start = snapshot.buffer_snapshot.anchor_after(hunk_start_point);
let multi_buffer_end = snapshot.buffer_snapshot.anchor_before(hunk_end_point);
let end = hunk_end_point.to_display_point(snapshot).row();

DisplayDiffHunk::Unfolded {
Expand Down
46 changes: 23 additions & 23 deletions crates/git/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,6 @@ use text::{Anchor, BufferId, BufferSnapshot, OffsetRangeExt, Point};
pub use git2 as libgit;
use libgit::{DiffLineType as GitDiffLineType, DiffOptions as GitOptions, Patch as GitPatch};

pub fn diff<'a>(head: &'a str, current: &'a str) -> Option<GitPatch<'a>> {
let mut options = GitOptions::default();
options.context_lines(0);

let patch = GitPatch::from_buffers(
head.as_bytes(),
None,
current.as_bytes(),
None,
Some(&mut options),
);

match patch {
Ok(patch) => Some(patch),

Err(err) => {
log::error!("`GitPatch::from_buffers` failed: {}", err);
None
}
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum DiffHunkStatus {
Added,
Expand Down Expand Up @@ -205,7 +183,7 @@ impl BufferDiff {
let mut tree = SumTree::new();

let buffer_text = buffer.as_rope().to_string();
let patch = diff(diff_base, &buffer_text);
let patch = Self::diff(diff_base, &buffer_text);

if let Some(patch) = patch {
let mut divergence = 0;
Expand All @@ -226,6 +204,28 @@ impl BufferDiff {
self.hunks_intersecting_range(start..end, text)
}

fn diff<'a>(head: &'a str, current: &'a str) -> Option<GitPatch<'a>> {
let mut options = GitOptions::default();
options.context_lines(0);

let patch = GitPatch::from_buffers(
head.as_bytes(),
None,
current.as_bytes(),
None,
Some(&mut options),
);

match patch {
Ok(patch) => Some(patch),

Err(err) => {
log::error!("`GitPatch::from_buffers` failed: {}", err);
None
}
}
}

fn process_patch_hunk(
patch: &GitPatch<'_>,
hunk_index: usize,
Expand Down
12 changes: 6 additions & 6 deletions crates/multi_buffer/src/multi_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,19 @@ impl MultiBuffer {
show_headers: true,
..MultiBufferSnapshot::default()
}),
buffers: Default::default(),
subscriptions: Default::default(),
buffers: RefCell::default(),
subscriptions: Topic::default(),
singleton: false,
capability,
replica_id,
title: None,
history: History {
next_transaction_id: Default::default(),
undo_stack: Default::default(),
redo_stack: Default::default(),
next_transaction_id: clock::Lamport::default(),
undo_stack: Vec::new(),
redo_stack: Vec::new(),
transaction_depth: 0,
group_interval: Duration::from_millis(300),
},
title: Default::default(),
}
}

Expand Down

0 comments on commit b6d3e92

Please sign in to comment.