Use replace blocks for patches (#20605)

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Richard <richard@zed.dev>
This commit is contained in:
Antonio Scandurra
2024-11-13 18:55:23 +01:00
committed by GitHub
co-authored by Max Richard
parent 96deabfb78
commit 92613a8904
13 changed files with 925 additions and 918 deletions
+24 -23
View File
@@ -596,10 +596,10 @@ fn test_clone(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, cx| {
editor.change_selections(None, cx, |s| s.select_ranges(selection_ranges.clone()));
editor.fold_ranges(
[
(Point::new(1, 0)..Point::new(2, 0), FoldPlaceholder::test()),
(Point::new(3, 0)..Point::new(4, 0), FoldPlaceholder::test()),
editor.fold_creases(
vec![
Crease::simple(Point::new(1, 0)..Point::new(2, 0), FoldPlaceholder::test()),
Crease::simple(Point::new(3, 0)..Point::new(4, 0), FoldPlaceholder::test()),
],
true,
cx,
@@ -1283,11 +1283,11 @@ fn test_move_cursor_multibyte(cx: &mut TestAppContext) {
assert_eq!('α'.len_utf8(), 2);
_ = view.update(cx, |view, cx| {
view.fold_ranges(
view.fold_creases(
vec![
(Point::new(0, 6)..Point::new(0, 12), FoldPlaceholder::test()),
(Point::new(1, 2)..Point::new(1, 4), FoldPlaceholder::test()),
(Point::new(2, 4)..Point::new(2, 8), FoldPlaceholder::test()),
Crease::simple(Point::new(0, 6)..Point::new(0, 12), FoldPlaceholder::test()),
Crease::simple(Point::new(1, 2)..Point::new(1, 4), FoldPlaceholder::test()),
Crease::simple(Point::new(2, 4)..Point::new(2, 8), FoldPlaceholder::test()),
],
true,
cx,
@@ -3875,11 +3875,11 @@ fn test_move_line_up_down(cx: &mut TestAppContext) {
build_editor(buffer, cx)
});
_ = view.update(cx, |view, cx| {
view.fold_ranges(
view.fold_creases(
vec![
(Point::new(0, 2)..Point::new(1, 2), FoldPlaceholder::test()),
(Point::new(2, 3)..Point::new(4, 1), FoldPlaceholder::test()),
(Point::new(7, 0)..Point::new(8, 4), FoldPlaceholder::test()),
Crease::simple(Point::new(0, 2)..Point::new(1, 2), FoldPlaceholder::test()),
Crease::simple(Point::new(2, 3)..Point::new(4, 1), FoldPlaceholder::test()),
Crease::simple(Point::new(7, 0)..Point::new(8, 4), FoldPlaceholder::test()),
],
true,
cx,
@@ -3980,7 +3980,7 @@ fn test_move_line_up_down_with_blocks(cx: &mut TestAppContext) {
style: BlockStyle::Fixed,
placement: BlockPlacement::Below(snapshot.anchor_after(Point::new(2, 0))),
height: 1,
render: Box::new(|_| div().into_any()),
render: Arc::new(|_| div().into_any()),
priority: 0,
}],
Some(Autoscroll::fit()),
@@ -4022,7 +4022,7 @@ async fn test_selections_and_replace_blocks(cx: &mut TestAppContext) {
placement,
height: 4,
style: BlockStyle::Sticky,
render: Box::new(|_| gpui::div().into_any_element()),
render: Arc::new(|_| gpui::div().into_any_element()),
priority: 0,
}],
None,
@@ -4717,11 +4717,11 @@ fn test_split_selection_into_lines(cx: &mut TestAppContext) {
build_editor(buffer, cx)
});
_ = view.update(cx, |view, cx| {
view.fold_ranges(
view.fold_creases(
vec![
(Point::new(0, 2)..Point::new(1, 2), FoldPlaceholder::test()),
(Point::new(2, 3)..Point::new(4, 1), FoldPlaceholder::test()),
(Point::new(7, 0)..Point::new(8, 4), FoldPlaceholder::test()),
Crease::simple(Point::new(0, 2)..Point::new(1, 2), FoldPlaceholder::test()),
Crease::simple(Point::new(2, 3)..Point::new(4, 1), FoldPlaceholder::test()),
Crease::simple(Point::new(7, 0)..Point::new(8, 4), FoldPlaceholder::test()),
],
true,
cx,
@@ -5398,13 +5398,13 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) {
// Ensure that we keep expanding the selection if the larger selection starts or ends within
// a fold.
editor.update(cx, |view, cx| {
view.fold_ranges(
view.fold_creases(
vec![
(
Crease::simple(
Point::new(0, 21)..Point::new(0, 24),
FoldPlaceholder::test(),
),
(
Crease::simple(
Point::new(3, 20)..Point::new(3, 22),
FoldPlaceholder::test(),
),
@@ -13139,7 +13139,7 @@ fn test_crease_insertion_and_rendering(cx: &mut TestAppContext) {
callback: Arc<dyn Fn(bool, &mut WindowContext) + Send + Sync>,
}
let crease = Crease::new(
let crease = Crease::inline(
range,
FoldPlaceholder::test(),
{
@@ -13158,7 +13158,8 @@ fn test_crease_insertion_and_rendering(cx: &mut TestAppContext) {
editor.insert_creases(Some(crease), cx);
let snapshot = editor.snapshot(cx);
let _div = snapshot.render_fold_toggle(MultiBufferRow(1), false, cx.view().clone(), cx);
let _div =
snapshot.render_crease_toggle(MultiBufferRow(1), false, cx.view().clone(), cx);
snapshot
})
.unwrap();