buffer_divergence doesn't seem to be a concept that needs to be tracked
This commit is contained in:
parent
e0ea932fa7
commit
2f7283fd13
1 changed files with 5 additions and 17 deletions
|
@ -185,16 +185,8 @@ impl BufferDiff {
|
||||||
let patch = Self::diff(&head_text, &buffer_text);
|
let patch = Self::diff(&head_text, &buffer_text);
|
||||||
|
|
||||||
if let Some(patch) = patch {
|
if let Some(patch) = patch {
|
||||||
let mut buffer_divergence = 0;
|
|
||||||
|
|
||||||
for hunk_index in 0..patch.num_hunks() {
|
for hunk_index in 0..patch.num_hunks() {
|
||||||
let patch = Self::process_patch_hunk(
|
let patch = Self::process_patch_hunk(&patch, hunk_index, buffer);
|
||||||
&mut buffer_divergence,
|
|
||||||
&patch,
|
|
||||||
hunk_index,
|
|
||||||
buffer,
|
|
||||||
);
|
|
||||||
|
|
||||||
tree.push(patch, buffer);
|
tree.push(patch, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,7 +344,6 @@ impl BufferDiff {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_patch_hunk<'a>(
|
fn process_patch_hunk<'a>(
|
||||||
buffer_divergence: &mut isize,
|
|
||||||
patch: &GitPatch<'a>,
|
patch: &GitPatch<'a>,
|
||||||
hunk_index: usize,
|
hunk_index: usize,
|
||||||
buffer: &text::BufferSnapshot,
|
buffer: &text::BufferSnapshot,
|
||||||
|
@ -363,18 +354,17 @@ impl BufferDiff {
|
||||||
for line_index in 0..patch.num_lines_in_hunk(hunk_index).unwrap() {
|
for line_index in 0..patch.num_lines_in_hunk(hunk_index).unwrap() {
|
||||||
let line = patch.line_in_hunk(hunk_index, line_index).unwrap();
|
let line = patch.line_in_hunk(hunk_index, line_index).unwrap();
|
||||||
let kind = line.origin_value();
|
let kind = line.origin_value();
|
||||||
println!("line index: {line_index}, kind: {kind:?}");
|
|
||||||
let content_offset = line.content_offset() as isize;
|
let content_offset = line.content_offset() as isize;
|
||||||
|
|
||||||
match (kind, &mut buffer_byte_range, &mut head_byte_range) {
|
match (kind, &mut buffer_byte_range, &mut head_byte_range) {
|
||||||
(GitDiffLineType::Addition, None, _) => {
|
(GitDiffLineType::Addition, None, _) => {
|
||||||
let start = *buffer_divergence + content_offset;
|
let end = content_offset + line.content().len() as isize;
|
||||||
let end = start + line.content().len() as isize;
|
buffer_byte_range = Some(content_offset as usize..end as usize);
|
||||||
buffer_byte_range = Some(start as usize..end as usize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(GitDiffLineType::Addition, Some(buffer_byte_range), _) => {
|
(GitDiffLineType::Addition, Some(buffer_byte_range), _) => {
|
||||||
buffer_byte_range.end = content_offset as usize;
|
let end = content_offset + line.content().len() as isize;
|
||||||
|
buffer_byte_range.end = end as usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
(GitDiffLineType::Deletion, _, None) => {
|
(GitDiffLineType::Deletion, _, None) => {
|
||||||
|
@ -396,8 +386,6 @@ impl BufferDiff {
|
||||||
//unwrap_or addition without deletion
|
//unwrap_or addition without deletion
|
||||||
let head_byte_range = head_byte_range.unwrap_or(0..0);
|
let head_byte_range = head_byte_range.unwrap_or(0..0);
|
||||||
|
|
||||||
*buffer_divergence += buffer_byte_range.len() as isize - head_byte_range.len() as isize;
|
|
||||||
|
|
||||||
DiffHunk {
|
DiffHunk {
|
||||||
buffer_range: buffer.anchor_before(buffer_byte_range.start)
|
buffer_range: buffer.anchor_before(buffer_byte_range.start)
|
||||||
..buffer.anchor_before(buffer_byte_range.end),
|
..buffer.anchor_before(buffer_byte_range.end),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue