Preserve cursor position when resetting excerpts (#27850)
Release Notes: - N/A --------- Co-authored-by: Nathan Sobo <nathan@zed.dev> Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
f859b328f0
commit
76871056f5
19 changed files with 299 additions and 617 deletions
|
@ -2125,26 +2125,17 @@ mod tests {
|
|||
let mut multi_buffer = MultiBuffer::new(Capability::ReadWrite);
|
||||
excerpt_ids.extend(multi_buffer.push_excerpts(
|
||||
buffer1.clone(),
|
||||
[ExcerptRange {
|
||||
context: 0..buffer1.read(cx).len(),
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(0..buffer1.read(cx).len())],
|
||||
cx,
|
||||
));
|
||||
excerpt_ids.extend(multi_buffer.push_excerpts(
|
||||
buffer2.clone(),
|
||||
[ExcerptRange {
|
||||
context: 0..buffer2.read(cx).len(),
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(0..buffer2.read(cx).len())],
|
||||
cx,
|
||||
));
|
||||
excerpt_ids.extend(multi_buffer.push_excerpts(
|
||||
buffer3.clone(),
|
||||
[ExcerptRange {
|
||||
context: 0..buffer3.read(cx).len(),
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(0..buffer3.read(cx).len())],
|
||||
cx,
|
||||
));
|
||||
|
||||
|
|
|
@ -3165,18 +3165,12 @@ fn test_indent_outdent_with_excerpts(cx: &mut TestAppContext) {
|
|||
let mut multibuffer = MultiBuffer::new(ReadWrite);
|
||||
multibuffer.push_excerpts(
|
||||
toml_buffer.clone(),
|
||||
[ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(2, 0),
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(Point::new(0, 0)..Point::new(2, 0))],
|
||||
cx,
|
||||
);
|
||||
multibuffer.push_excerpts(
|
||||
rust_buffer.clone(),
|
||||
[ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(1, 0),
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(Point::new(0, 0)..Point::new(1, 0))],
|
||||
cx,
|
||||
);
|
||||
multibuffer
|
||||
|
@ -7859,54 +7853,27 @@ async fn test_multibuffer_format_during_save(cx: &mut TestAppContext) {
|
|||
multi_buffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
multi_buffer.push_excerpts(
|
||||
buffer_2.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
multi_buffer.push_excerpts(
|
||||
buffer_3.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
|
@ -10685,14 +10652,8 @@ fn test_editing_disjoint_excerpts(cx: &mut TestAppContext) {
|
|||
multibuffer.push_excerpts(
|
||||
buffer.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(0, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(1, 0)..Point::new(1, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(0, 4)),
|
||||
ExcerptRange::new(Point::new(1, 0)..Point::new(1, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
|
@ -10758,10 +10719,7 @@ fn test_editing_overlapping_excerpts(cx: &mut TestAppContext) {
|
|||
);
|
||||
let excerpt_ranges = markers.into_iter().map(|marker| {
|
||||
let context = excerpt_ranges.remove(&marker).unwrap()[0].clone();
|
||||
ExcerptRange {
|
||||
context,
|
||||
primary: None,
|
||||
}
|
||||
ExcerptRange::new(context.clone())
|
||||
});
|
||||
let buffer = cx.new(|cx| Buffer::local(initial_text, cx));
|
||||
let multibuffer = cx.new(|cx| {
|
||||
|
@ -10829,14 +10787,8 @@ fn test_refresh_selections(cx: &mut TestAppContext) {
|
|||
.push_excerpts(
|
||||
buffer.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(1, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(1, 0)..Point::new(2, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(1, 4)),
|
||||
ExcerptRange::new(Point::new(1, 0)..Point::new(2, 4)),
|
||||
],
|
||||
cx,
|
||||
)
|
||||
|
@ -10920,14 +10872,8 @@ fn test_refresh_selections_while_selecting_with_mouse(cx: &mut TestAppContext) {
|
|||
.push_excerpts(
|
||||
buffer.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(1, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(1, 0)..Point::new(2, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(1, 4)),
|
||||
ExcerptRange::new(Point::new(1, 0)..Point::new(2, 4)),
|
||||
],
|
||||
cx,
|
||||
)
|
||||
|
@ -11398,34 +11344,16 @@ async fn test_following_with_multiple_excerpts(cx: &mut TestAppContext) {
|
|||
let excerpt_ids = multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: 1..6,
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: 12..15,
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: 0..3,
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(1..6),
|
||||
ExcerptRange::new(12..15),
|
||||
ExcerptRange::new(0..3),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
multibuffer.insert_excerpts_after(
|
||||
excerpt_ids[0],
|
||||
buffer_2.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: 8..12,
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: 0..6,
|
||||
primary: None,
|
||||
},
|
||||
],
|
||||
[ExcerptRange::new(8..12), ExcerptRange::new(0..6)],
|
||||
cx,
|
||||
);
|
||||
});
|
||||
|
@ -13599,54 +13527,27 @@ async fn test_multibuffer_reverts(cx: &mut TestAppContext) {
|
|||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_2.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_3.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
|
@ -13766,54 +13667,27 @@ async fn test_mutlibuffer_in_navigation_history(cx: &mut TestAppContext) {
|
|||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_2.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_3.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
|
@ -14266,54 +14140,27 @@ async fn test_toggle_diff_expand_in_multi_buffer(cx: &mut TestAppContext) {
|
|||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 3),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 3)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_2.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 3),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 3)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_3.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 3),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 3)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
|
@ -14422,18 +14269,9 @@ async fn test_expand_diff_hunk_at_excerpt_boundary(cx: &mut TestAppContext) {
|
|||
multibuffer.push_excerpts(
|
||||
buffer.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(2, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(4, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(2, 0)),
|
||||
ExcerptRange::new(Point::new(4, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 0)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
|
@ -16613,54 +16451,27 @@ async fn test_folding_buffers(cx: &mut TestAppContext) {
|
|||
multi_buffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
multi_buffer.push_excerpts(
|
||||
buffer_2.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
multi_buffer.push_excerpts(
|
||||
buffer_3.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(5, 0)..Point::new(7, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(9, 0)..Point::new(10, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0)),
|
||||
ExcerptRange::new(Point::new(5, 0)..Point::new(7, 0)),
|
||||
ExcerptRange::new(Point::new(9, 0)..Point::new(10, 4)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
|
@ -16807,26 +16618,17 @@ async fn test_folding_buffers_with_one_excerpt(cx: &mut TestAppContext) {
|
|||
let mut multi_buffer = MultiBuffer::new(ReadWrite);
|
||||
multi_buffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0))],
|
||||
cx,
|
||||
);
|
||||
multi_buffer.push_excerpts(
|
||||
buffer_2.clone(),
|
||||
[ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0))],
|
||||
cx,
|
||||
);
|
||||
multi_buffer.push_excerpts(
|
||||
buffer_3.clone(),
|
||||
[ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(3, 0),
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(Point::new(0, 0)..Point::new(3, 0))],
|
||||
cx,
|
||||
);
|
||||
multi_buffer
|
||||
|
@ -16939,14 +16741,13 @@ async fn test_folding_buffer_when_multibuffer_has_only_one_excerpt(cx: &mut Test
|
|||
let mut multi_buffer = MultiBuffer::new(ReadWrite);
|
||||
multi_buffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[ExcerptRange {
|
||||
context: Point::new(0, 0)
|
||||
[ExcerptRange::new(
|
||||
Point::new(0, 0)
|
||||
..Point::new(
|
||||
sample_text.chars().filter(|&c| c == '\n').count() as u32 + 1,
|
||||
0,
|
||||
),
|
||||
primary: None,
|
||||
}],
|
||||
)],
|
||||
cx,
|
||||
);
|
||||
multi_buffer
|
||||
|
|
|
@ -5628,10 +5628,7 @@ fn header_jump_data(
|
|||
) -> JumpData {
|
||||
let range = &for_excerpt.range;
|
||||
let buffer = &for_excerpt.buffer;
|
||||
let jump_anchor = range
|
||||
.primary
|
||||
.as_ref()
|
||||
.map_or(range.context.start, |primary| primary.start);
|
||||
let jump_anchor = range.primary.start;
|
||||
|
||||
let excerpt_start = range.context.start;
|
||||
let jump_position = language::ToPoint::to_point(&jump_anchor, buffer);
|
||||
|
|
|
@ -2565,60 +2565,24 @@ pub mod tests {
|
|||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(2, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(4, 0)..Point::new(11, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(22, 0)..Point::new(33, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(44, 0)..Point::new(55, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(56, 0)..Point::new(66, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(67, 0)..Point::new(77, 0),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(2, 0)),
|
||||
ExcerptRange::new(Point::new(4, 0)..Point::new(11, 0)),
|
||||
ExcerptRange::new(Point::new(22, 0)..Point::new(33, 0)),
|
||||
ExcerptRange::new(Point::new(44, 0)..Point::new(55, 0)),
|
||||
ExcerptRange::new(Point::new(56, 0)..Point::new(66, 0)),
|
||||
ExcerptRange::new(Point::new(67, 0)..Point::new(77, 0)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_2.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 1)..Point::new(2, 1),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(4, 1)..Point::new(11, 1),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(22, 1)..Point::new(33, 1),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(44, 1)..Point::new(55, 1),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(56, 1)..Point::new(66, 1),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(67, 1)..Point::new(77, 1),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 1)..Point::new(2, 1)),
|
||||
ExcerptRange::new(Point::new(4, 1)..Point::new(11, 1)),
|
||||
ExcerptRange::new(Point::new(22, 1)..Point::new(33, 1)),
|
||||
ExcerptRange::new(Point::new(44, 1)..Point::new(55, 1)),
|
||||
ExcerptRange::new(Point::new(56, 1)..Point::new(66, 1)),
|
||||
ExcerptRange::new(Point::new(67, 1)..Point::new(77, 1)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
|
@ -2907,18 +2871,12 @@ pub mod tests {
|
|||
let (buffer_1_excerpts, buffer_2_excerpts) = multibuffer.update(cx, |multibuffer, cx| {
|
||||
let buffer_1_excerpts = multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(2, 0),
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(Point::new(0, 0)..Point::new(2, 0))],
|
||||
cx,
|
||||
);
|
||||
let buffer_2_excerpts = multibuffer.push_excerpts(
|
||||
buffer_2.clone(),
|
||||
[ExcerptRange {
|
||||
context: Point::new(0, 1)..Point::new(2, 1),
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(Point::new(0, 1)..Point::new(2, 1))],
|
||||
cx,
|
||||
);
|
||||
(buffer_1_excerpts, buffer_2_excerpts)
|
||||
|
|
|
@ -200,14 +200,8 @@ impl FollowableItem for Editor {
|
|||
buffer_id: buffer.remote_id().into(),
|
||||
context_start: Some(serialize_text_anchor(&range.context.start)),
|
||||
context_end: Some(serialize_text_anchor(&range.context.end)),
|
||||
primary_start: range
|
||||
.primary
|
||||
.as_ref()
|
||||
.map(|range| serialize_text_anchor(&range.start)),
|
||||
primary_end: range
|
||||
.primary
|
||||
.as_ref()
|
||||
.map(|range| serialize_text_anchor(&range.end)),
|
||||
primary_start: Some(serialize_text_anchor(&range.primary.start)),
|
||||
primary_end: Some(serialize_text_anchor(&range.primary.end)),
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -481,14 +475,8 @@ fn serialize_excerpt(
|
|||
buffer_id: buffer_id.into(),
|
||||
context_start: Some(serialize_text_anchor(&range.context.start)),
|
||||
context_end: Some(serialize_text_anchor(&range.context.end)),
|
||||
primary_start: range
|
||||
.primary
|
||||
.as_ref()
|
||||
.map(|r| serialize_text_anchor(&r.start)),
|
||||
primary_end: range
|
||||
.primary
|
||||
.as_ref()
|
||||
.map(|r| serialize_text_anchor(&r.end)),
|
||||
primary_start: Some(serialize_text_anchor(&range.primary.start)),
|
||||
primary_end: Some(serialize_text_anchor(&range.primary.end)),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -521,7 +509,8 @@ fn deserialize_excerpt_range(excerpt: proto::Excerpt) -> Option<ExcerptRange<lan
|
|||
let start = language::proto::deserialize_anchor(start)?;
|
||||
let end = language::proto::deserialize_anchor(end)?;
|
||||
Some(start..end)
|
||||
});
|
||||
})
|
||||
.unwrap_or_else(|| context.clone());
|
||||
Some(ExcerptRange { context, primary })
|
||||
}
|
||||
|
||||
|
|
|
@ -814,26 +814,17 @@ mod jsx_tag_autoclose_tests {
|
|||
let mut buf = MultiBuffer::new(language::Capability::ReadWrite);
|
||||
buf.push_excerpts(
|
||||
buffer_a,
|
||||
[ExcerptRange {
|
||||
context: text::Anchor::MIN..text::Anchor::MAX,
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(text::Anchor::MIN..text::Anchor::MAX)],
|
||||
cx,
|
||||
);
|
||||
buf.push_excerpts(
|
||||
buffer_b,
|
||||
[ExcerptRange {
|
||||
context: text::Anchor::MIN..text::Anchor::MAX,
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(text::Anchor::MIN..text::Anchor::MAX)],
|
||||
cx,
|
||||
);
|
||||
buf.push_excerpts(
|
||||
buffer_c,
|
||||
[ExcerptRange {
|
||||
context: text::Anchor::MIN..text::Anchor::MAX,
|
||||
primary: None,
|
||||
}],
|
||||
[ExcerptRange::new(text::Anchor::MIN..text::Anchor::MAX)],
|
||||
cx,
|
||||
);
|
||||
buf
|
||||
|
|
|
@ -1089,14 +1089,8 @@ mod tests {
|
|||
multibuffer.push_excerpts(
|
||||
buffer.clone(),
|
||||
[
|
||||
ExcerptRange {
|
||||
context: Point::new(0, 0)..Point::new(1, 4),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange {
|
||||
context: Point::new(2, 0)..Point::new(3, 2),
|
||||
primary: None,
|
||||
},
|
||||
ExcerptRange::new(Point::new(0, 0)..Point::new(1, 4)),
|
||||
ExcerptRange::new(Point::new(2, 0)..Point::new(3, 2)),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
|
|
|
@ -51,7 +51,7 @@ struct RecalculateDiff {
|
|||
struct BranchBufferSemanticsProvider(Rc<dyn SemanticsProvider>);
|
||||
|
||||
impl ProposedChangesEditor {
|
||||
pub fn new<T: ToOffset>(
|
||||
pub fn new<T: Clone + ToOffset>(
|
||||
title: impl Into<SharedString>,
|
||||
locations: Vec<ProposedChangeLocation<T>>,
|
||||
project: Option<Entity<Project>>,
|
||||
|
@ -140,7 +140,7 @@ impl ProposedChangesEditor {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn reset_locations<T: ToOffset>(
|
||||
pub fn reset_locations<T: Clone + ToOffset>(
|
||||
&mut self,
|
||||
locations: Vec<ProposedChangeLocation<T>>,
|
||||
window: &mut Window,
|
||||
|
@ -202,10 +202,10 @@ impl ProposedChangesEditor {
|
|||
self.multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.push_excerpts(
|
||||
branch_buffer,
|
||||
location.ranges.into_iter().map(|range| ExcerptRange {
|
||||
context: range,
|
||||
primary: None,
|
||||
}),
|
||||
location
|
||||
.ranges
|
||||
.into_iter()
|
||||
.map(|range| ExcerptRange::new(range)),
|
||||
cx,
|
||||
);
|
||||
});
|
||||
|
|
|
@ -120,10 +120,9 @@ impl EditorTestContext {
|
|||
let buffer = cx.new(|cx| Buffer::local(text, cx));
|
||||
multibuffer.push_excerpts(
|
||||
buffer,
|
||||
ranges.into_iter().map(|range| ExcerptRange {
|
||||
context: range,
|
||||
primary: None,
|
||||
}),
|
||||
ranges
|
||||
.into_iter()
|
||||
.map(|range| ExcerptRange::new(range.clone())),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue