Reduce display_map snapshot creation (#39354)

Re-applies https://github.com/zed-industries/zed/pull/30840

This PR re-applies the initial
[PR](https://github.com/zed-industries/zed/pull/30840). As it was closed
because it was hard to land, because of the many conflicts. This PR
re-applies the changes for it.

In several cases we were creating multiple display_map
snapshots within the same root-level function call.
Creating a display_map snapshot is quite slow, and in some
cases we were creating the snapshot multiple times.

Release Notes:

- N/A
This commit is contained in:
Remco Smits
2025-10-17 21:56:57 +02:00
committed by GitHub
parent ef5b8c6fed
commit 7e97fcaacb
60 changed files with 853 additions and 426 deletions
+193 -70
View File
@@ -219,7 +219,10 @@ fn test_undo_redo_with_selection_restoration(cx: &mut TestAppContext) {
editor.insert("cd", window, cx);
editor.end_transaction_at(now, cx);
assert_eq!(editor.text(cx), "12cd56");
assert_eq!(editor.selections.ranges(cx), vec![4..4]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
vec![4..4]
);
editor.start_transaction_at(now, window, cx);
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
@@ -228,7 +231,10 @@ fn test_undo_redo_with_selection_restoration(cx: &mut TestAppContext) {
editor.insert("e", window, cx);
editor.end_transaction_at(now, cx);
assert_eq!(editor.text(cx), "12cde6");
assert_eq!(editor.selections.ranges(cx), vec![5..5]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
vec![5..5]
);
now += group_interval + Duration::from_millis(1);
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
@@ -244,30 +250,45 @@ fn test_undo_redo_with_selection_restoration(cx: &mut TestAppContext) {
});
assert_eq!(editor.text(cx), "ab2cde6");
assert_eq!(editor.selections.ranges(cx), vec![3..3]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
vec![3..3]
);
// Last transaction happened past the group interval in a different editor.
// Undo it individually and don't restore selections.
editor.undo(&Undo, window, cx);
assert_eq!(editor.text(cx), "12cde6");
assert_eq!(editor.selections.ranges(cx), vec![2..2]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
vec![2..2]
);
// First two transactions happened within the group interval in this editor.
// Undo them together and restore selections.
editor.undo(&Undo, window, cx);
editor.undo(&Undo, window, cx); // Undo stack is empty here, so this is a no-op.
assert_eq!(editor.text(cx), "123456");
assert_eq!(editor.selections.ranges(cx), vec![0..0]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
vec![0..0]
);
// Redo the first two transactions together.
editor.redo(&Redo, window, cx);
assert_eq!(editor.text(cx), "12cde6");
assert_eq!(editor.selections.ranges(cx), vec![5..5]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
vec![5..5]
);
// Redo the last transaction on its own.
editor.redo(&Redo, window, cx);
assert_eq!(editor.text(cx), "ab2cde6");
assert_eq!(editor.selections.ranges(cx), vec![6..6]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
vec![6..6]
);
// Test empty transactions.
editor.start_transaction_at(now, window, cx);
@@ -770,10 +791,14 @@ fn test_clone(cx: &mut TestAppContext) {
);
assert_set_eq!(
cloned_editor
.update(cx, |editor, _, cx| editor.selections.ranges::<Point>(cx))
.update(cx, |editor, _, cx| editor
.selections
.ranges::<Point>(&editor.display_snapshot(cx)))
.unwrap(),
editor
.update(cx, |editor, _, cx| editor.selections.ranges(cx))
.update(cx, |editor, _, cx| editor
.selections
.ranges(&editor.display_snapshot(cx)))
.unwrap()
);
assert_set_eq!(
@@ -3161,7 +3186,7 @@ fn test_newline_with_old_selections(cx: &mut TestAppContext) {
);
});
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
&[
Point::new(1, 2)..Point::new(1, 2),
Point::new(2, 2)..Point::new(2, 2),
@@ -3183,7 +3208,7 @@ fn test_newline_with_old_selections(cx: &mut TestAppContext) {
// The selections are moved after the inserted newlines
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
&[
Point::new(2, 0)..Point::new(2, 0),
Point::new(4, 0)..Point::new(4, 0),
@@ -3673,13 +3698,19 @@ fn test_insert_with_old_selections(cx: &mut TestAppContext) {
buffer.edit([(2..5, ""), (10..13, ""), (18..21, "")], None, cx);
assert_eq!(buffer.read(cx).text(), "a(), b(), c()".unindent());
});
assert_eq!(editor.selections.ranges(cx), &[2..2, 7..7, 12..12],);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
&[2..2, 7..7, 12..12],
);
editor.insert("Z", window, cx);
assert_eq!(editor.text(cx), "a(Z), b(Z), c(Z)");
// The selections are moved after the inserted characters
assert_eq!(editor.selections.ranges(cx), &[3..3, 9..9, 15..15],);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
&[3..3, 9..9, 15..15],
);
});
}
@@ -4439,7 +4470,9 @@ fn test_join_lines_with_single_selection(cx: &mut TestAppContext) {
let buffer = buffer.read(cx).as_singleton().unwrap();
assert_eq!(
editor.selections.ranges::<Point>(cx),
editor
.selections
.ranges::<Point>(&editor.display_snapshot(cx)),
&[Point::new(0, 0)..Point::new(0, 0)]
);
@@ -4447,7 +4480,9 @@ fn test_join_lines_with_single_selection(cx: &mut TestAppContext) {
editor.join_lines(&JoinLines, window, cx);
assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd\n\n");
assert_eq!(
editor.selections.ranges::<Point>(cx),
editor
.selections
.ranges::<Point>(&editor.display_snapshot(cx)),
&[Point::new(0, 3)..Point::new(0, 3)]
);
@@ -4458,7 +4493,9 @@ fn test_join_lines_with_single_selection(cx: &mut TestAppContext) {
editor.join_lines(&JoinLines, window, cx);
assert_eq!(buffer.read(cx).text(), "aaa bbb ccc ddd\n\n");
assert_eq!(
editor.selections.ranges::<Point>(cx),
editor
.selections
.ranges::<Point>(&editor.display_snapshot(cx)),
&[Point::new(0, 11)..Point::new(0, 11)]
);
@@ -4466,7 +4503,9 @@ fn test_join_lines_with_single_selection(cx: &mut TestAppContext) {
editor.undo(&Undo, window, cx);
assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd\n\n");
assert_eq!(
editor.selections.ranges::<Point>(cx),
editor
.selections
.ranges::<Point>(&editor.display_snapshot(cx)),
&[Point::new(0, 5)..Point::new(2, 2)]
);
@@ -4477,7 +4516,9 @@ fn test_join_lines_with_single_selection(cx: &mut TestAppContext) {
editor.join_lines(&JoinLines, window, cx);
assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd\n");
assert_eq!(
editor.selections.ranges::<Point>(cx),
editor
.selections
.ranges::<Point>(&editor.display_snapshot(cx)),
[Point::new(2, 3)..Point::new(2, 3)]
);
@@ -4485,7 +4526,9 @@ fn test_join_lines_with_single_selection(cx: &mut TestAppContext) {
editor.join_lines(&JoinLines, window, cx);
assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd");
assert_eq!(
editor.selections.ranges::<Point>(cx),
editor
.selections
.ranges::<Point>(&editor.display_snapshot(cx)),
[Point::new(2, 3)..Point::new(2, 3)]
);
@@ -4493,7 +4536,9 @@ fn test_join_lines_with_single_selection(cx: &mut TestAppContext) {
editor.join_lines(&JoinLines, window, cx);
assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd");
assert_eq!(
editor.selections.ranges::<Point>(cx),
editor
.selections
.ranges::<Point>(&editor.display_snapshot(cx)),
[Point::new(2, 3)..Point::new(2, 3)]
);
@@ -4550,7 +4595,9 @@ fn test_join_lines_with_multi_selection(cx: &mut TestAppContext) {
assert_eq!(buffer.read(cx).text(), "aaa bbb ccc\nddd\n");
assert_eq!(
editor.selections.ranges::<Point>(cx),
editor
.selections
.ranges::<Point>(&editor.display_snapshot(cx)),
[
Point::new(0, 7)..Point::new(0, 7),
Point::new(1, 3)..Point::new(1, 3)
@@ -5908,15 +5955,24 @@ fn test_transpose(cx: &mut TestAppContext) {
});
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "bac");
assert_eq!(editor.selections.ranges(cx), [2..2]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[2..2]
);
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "bca");
assert_eq!(editor.selections.ranges(cx), [3..3]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[3..3]
);
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "bac");
assert_eq!(editor.selections.ranges(cx), [3..3]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[3..3]
);
editor
});
@@ -5929,22 +5985,34 @@ fn test_transpose(cx: &mut TestAppContext) {
});
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "acb\nde");
assert_eq!(editor.selections.ranges(cx), [3..3]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[3..3]
);
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
s.select_ranges([4..4])
});
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "acbd\ne");
assert_eq!(editor.selections.ranges(cx), [5..5]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[5..5]
);
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "acbde\n");
assert_eq!(editor.selections.ranges(cx), [6..6]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[6..6]
);
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "acbd\ne");
assert_eq!(editor.selections.ranges(cx), [6..6]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[6..6]
);
editor
});
@@ -5957,23 +6025,38 @@ fn test_transpose(cx: &mut TestAppContext) {
});
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "bacd\ne");
assert_eq!(editor.selections.ranges(cx), [2..2, 3..3, 5..5]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[2..2, 3..3, 5..5]
);
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "bcade\n");
assert_eq!(editor.selections.ranges(cx), [3..3, 4..4, 6..6]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[3..3, 4..4, 6..6]
);
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "bcda\ne");
assert_eq!(editor.selections.ranges(cx), [4..4, 6..6]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[4..4, 6..6]
);
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "bcade\n");
assert_eq!(editor.selections.ranges(cx), [4..4, 6..6]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[4..4, 6..6]
);
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "bcaed\n");
assert_eq!(editor.selections.ranges(cx), [5..5, 6..6]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[5..5, 6..6]
);
editor
});
@@ -5986,15 +6069,24 @@ fn test_transpose(cx: &mut TestAppContext) {
});
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "🏀🍐✋");
assert_eq!(editor.selections.ranges(cx), [8..8]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[8..8]
);
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "🏀✋🍐");
assert_eq!(editor.selections.ranges(cx), [11..11]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[11..11]
);
editor.transpose(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "🏀🍐✋");
assert_eq!(editor.selections.ranges(cx), [11..11]);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
[11..11]
);
editor
});
@@ -9540,7 +9632,7 @@ async fn test_autoindent(cx: &mut TestAppContext) {
editor.newline(&Newline, window, cx);
assert_eq!(editor.text(cx), "fn a(\n \n) {\n \n}\n");
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
&[
Point::new(1, 4)..Point::new(1, 4),
Point::new(3, 4)..Point::new(3, 4),
@@ -9616,7 +9708,7 @@ async fn test_autoindent_disabled(cx: &mut TestAppContext) {
)
);
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
&[
Point::new(1, 0)..Point::new(1, 0),
Point::new(3, 0)..Point::new(3, 0),
@@ -10255,7 +10347,9 @@ async fn test_autoclose_with_embedded_language(cx: &mut TestAppContext) {
// Precondition: different languages are active at different locations.
cx.update_editor(|editor, window, cx| {
let snapshot = editor.snapshot(window, cx);
let cursors = editor.selections.ranges::<usize>(cx);
let cursors = editor
.selections
.ranges::<usize>(&editor.display_snapshot(cx));
let languages = cursors
.iter()
.map(|c| snapshot.language_at(c.start).unwrap().name())
@@ -10700,7 +10794,9 @@ async fn test_delete_autoclose_pair(cx: &mut TestAppContext) {
.unindent()
);
assert_eq!(
editor.selections.ranges::<Point>(cx),
editor
.selections
.ranges::<Point>(&editor.display_snapshot(cx)),
[
Point::new(0, 4)..Point::new(0, 4),
Point::new(1, 4)..Point::new(1, 4),
@@ -10720,7 +10816,9 @@ async fn test_delete_autoclose_pair(cx: &mut TestAppContext) {
.unindent()
);
assert_eq!(
editor.selections.ranges::<Point>(cx),
editor
.selections
.ranges::<Point>(&editor.display_snapshot(cx)),
[
Point::new(0, 2)..Point::new(0, 2),
Point::new(1, 2)..Point::new(1, 2),
@@ -10739,7 +10837,9 @@ async fn test_delete_autoclose_pair(cx: &mut TestAppContext) {
.unindent()
);
assert_eq!(
editor.selections.ranges::<Point>(cx),
editor
.selections
.ranges::<Point>(&editor.display_snapshot(cx)),
[
Point::new(0, 1)..Point::new(0, 1),
Point::new(1, 1)..Point::new(1, 1),
@@ -10945,7 +11045,12 @@ async fn test_snippet_placeholder_choices(cx: &mut TestAppContext) {
fn assert(editor: &mut Editor, cx: &mut Context<Editor>, marked_text: &str) {
let (expected_text, selection_ranges) = marked_text_ranges(marked_text, false);
assert_eq!(editor.text(cx), expected_text);
assert_eq!(editor.selections.ranges::<usize>(cx), selection_ranges);
assert_eq!(
editor
.selections
.ranges::<usize>(&editor.display_snapshot(cx)),
selection_ranges
);
}
assert(
@@ -10976,7 +11081,7 @@ async fn test_snippets(cx: &mut TestAppContext) {
let snippet = Snippet::parse("f(${1:one}, ${2:two}, ${1:three})$0").unwrap();
let insertion_ranges = editor
.selections
.all(cx)
.all(&editor.display_snapshot(cx))
.iter()
.map(|s| s.range())
.collect::<Vec<_>>();
@@ -11056,7 +11161,7 @@ async fn test_snippet_indentation(cx: &mut TestAppContext) {
.unwrap();
let insertion_ranges = editor
.selections
.all(cx)
.all(&editor.display_snapshot(cx))
.iter()
.map(|s| s.range())
.collect::<Vec<_>>();
@@ -15945,7 +16050,7 @@ fn test_editing_disjoint_excerpts(cx: &mut TestAppContext) {
editor.handle_input("X", window, cx);
assert_eq!(editor.text(cx), "Xaaaa\nXbbbb");
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
[
Point::new(0, 1)..Point::new(0, 1),
Point::new(1, 1)..Point::new(1, 1),
@@ -15959,7 +16064,7 @@ fn test_editing_disjoint_excerpts(cx: &mut TestAppContext) {
editor.backspace(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "Xa\nbbb");
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
[Point::new(1, 0)..Point::new(1, 0)]
);
@@ -15969,7 +16074,7 @@ fn test_editing_disjoint_excerpts(cx: &mut TestAppContext) {
editor.backspace(&Default::default(), window, cx);
assert_eq!(editor.text(cx), "X\nbb");
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
[Point::new(0, 1)..Point::new(0, 1)]
);
});
@@ -16027,7 +16132,10 @@ fn test_editing_overlapping_excerpts(cx: &mut TestAppContext) {
false,
);
assert_eq!(editor.text(cx), expected_text);
assert_eq!(editor.selections.ranges(cx), expected_selections);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
expected_selections
);
editor.newline(&Newline, window, cx);
let (expected_text, expected_selections) = marked_text_ranges(
@@ -16044,7 +16152,10 @@ fn test_editing_overlapping_excerpts(cx: &mut TestAppContext) {
false,
);
assert_eq!(editor.text(cx), expected_text);
assert_eq!(editor.selections.ranges(cx), expected_selections);
assert_eq!(
editor.selections.ranges(&editor.display_snapshot(cx)),
expected_selections
);
});
}
@@ -16085,7 +16196,7 @@ fn test_refresh_selections(cx: &mut TestAppContext) {
cx,
);
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
[
Point::new(1, 3)..Point::new(1, 3),
Point::new(2, 1)..Point::new(2, 1),
@@ -16098,7 +16209,7 @@ fn test_refresh_selections(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| s.refresh());
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
[
Point::new(1, 3)..Point::new(1, 3),
Point::new(2, 1)..Point::new(2, 1),
@@ -16112,7 +16223,7 @@ fn test_refresh_selections(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
// Removing an excerpt causes the first selection to become degenerate.
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
[
Point::new(0, 0)..Point::new(0, 0),
Point::new(0, 1)..Point::new(0, 1)
@@ -16123,7 +16234,7 @@ fn test_refresh_selections(cx: &mut TestAppContext) {
// location.
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| s.refresh());
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
[
Point::new(0, 1)..Point::new(0, 1),
Point::new(0, 3)..Point::new(0, 3)
@@ -16167,7 +16278,7 @@ fn test_refresh_selections_while_selecting_with_mouse(cx: &mut TestAppContext) {
cx,
);
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
[Point::new(1, 3)..Point::new(1, 3)]
);
editor
@@ -16178,14 +16289,14 @@ fn test_refresh_selections_while_selecting_with_mouse(cx: &mut TestAppContext) {
});
_ = editor.update(cx, |editor, window, cx| {
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
[Point::new(0, 0)..Point::new(0, 0)]
);
// Ensure we don't panic when selections are refreshed and that the pending selection is finalized.
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| s.refresh());
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
[Point::new(0, 3)..Point::new(0, 3)]
);
assert!(editor.selections.pending_anchor().is_some());
@@ -16435,7 +16546,10 @@ async fn test_following(cx: &mut TestAppContext) {
.await
.unwrap();
_ = follower.update(cx, |follower, _, cx| {
assert_eq!(follower.selections.ranges(cx), vec![1..1]);
assert_eq!(
follower.selections.ranges(&follower.display_snapshot(cx)),
vec![1..1]
);
});
assert!(*is_still_following.borrow());
assert_eq!(*follower_edit_event_count.borrow(), 0);
@@ -16488,7 +16602,10 @@ async fn test_following(cx: &mut TestAppContext) {
.unwrap();
_ = follower.update(cx, |follower, _, cx| {
assert_eq!(follower.scroll_position(cx), gpui::Point::new(1.5, 0.0));
assert_eq!(follower.selections.ranges(cx), vec![0..0]);
assert_eq!(
follower.selections.ranges(&follower.display_snapshot(cx)),
vec![0..0]
);
});
assert!(*is_still_following.borrow());
@@ -16512,7 +16629,10 @@ async fn test_following(cx: &mut TestAppContext) {
.await
.unwrap();
_ = follower.update(cx, |follower, _, cx| {
assert_eq!(follower.selections.ranges(cx), vec![0..0, 1..1]);
assert_eq!(
follower.selections.ranges(&follower.display_snapshot(cx)),
vec![0..0, 1..1]
);
});
assert!(*is_still_following.borrow());
@@ -16533,7 +16653,10 @@ async fn test_following(cx: &mut TestAppContext) {
.await
.unwrap();
_ = follower.update(cx, |follower, _, cx| {
assert_eq!(follower.selections.ranges(cx), vec![0..2]);
assert_eq!(
follower.selections.ranges(&follower.display_snapshot(cx)),
vec![0..2]
);
});
// Scrolling locally breaks the follow
@@ -22668,11 +22791,11 @@ fn add_log_breakpoint_at_cursor(
.first()
.and_then(|(anchor, bp)| bp.as_ref().map(|bp| (*anchor, bp.clone())))
.unwrap_or_else(|| {
let cursor_position: Point = editor.selections.newest(cx).head();
let snapshot = editor.snapshot(window, cx);
let cursor_position: Point =
editor.selections.newest(&snapshot.display_snapshot).head();
let breakpoint_position = editor
.snapshot(window, cx)
.display_snapshot
let breakpoint_position = snapshot
.buffer_snapshot()
.anchor_before(Point::new(cursor_position.row, 0));
@@ -23619,7 +23742,7 @@ println!("5");
assert_eq!(
editor
.selections
.all::<Point>(cx)
.all::<Point>(&editor.display_snapshot(cx))
.into_iter()
.map(|s| s.range())
.collect::<Vec<_>>(),
@@ -23662,7 +23785,7 @@ println!("5");
assert_eq!(
editor
.selections
.all::<Point>(cx)
.all::<Point>(&editor.display_snapshot(cx))
.into_iter()
.map(|s| s.range())
.collect::<Vec<_>>(),
@@ -23788,7 +23911,7 @@ println!("5");
assert_eq!(
editor
.selections
.all::<Point>(cx)
.all::<Point>(&editor.display_snapshot(cx))
.into_iter()
.map(|s| s.range())
.collect::<Vec<_>>(),
@@ -23814,7 +23937,7 @@ println!("5");
assert_eq!(
editor
.selections
.all::<Point>(cx)
.all::<Point>(&editor.display_snapshot(cx))
.into_iter()
.map(|s| s.range())
.collect::<Vec<_>>(),
@@ -25211,7 +25334,7 @@ fn assert_selection_ranges(marked_text: &str, editor: &mut Editor, cx: &mut Cont
let (text, ranges) = marked_text_ranges(marked_text, true);
assert_eq!(editor.text(cx), text);
assert_eq!(
editor.selections.ranges(cx),
editor.selections.ranges(&editor.display_snapshot(cx)),
ranges,
"Assert selections are {}",
marked_text