@@ -68,6 +68,12 @@ use workspace::{
register_project_item,
};
+fn display_ranges(editor: &Editor, cx: &mut Context<'_, Editor>) -> Vec<Range<DisplayPoint>> {
+ editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))
+}
+
#[gpui::test]
fn test_edit_events(cx: &mut TestAppContext) {
init_test(cx, |_| {});
@@ -416,7 +422,7 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) {
});
assert_eq!(
editor
- .update(cx, |editor, _, cx| editor.selections.display_ranges(cx))
+ .update(cx, |editor, _, cx| display_ranges(editor, cx))
.unwrap(),
[DisplayPoint::new(DisplayRow(2), 2)..DisplayPoint::new(DisplayRow(2), 2)]
);
@@ -433,7 +439,7 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) {
assert_eq!(
editor
- .update(cx, |editor, _, cx| editor.selections.display_ranges(cx))
+ .update(cx, |editor, _, cx| display_ranges(editor, cx))
.unwrap(),
[DisplayPoint::new(DisplayRow(2), 2)..DisplayPoint::new(DisplayRow(3), 3)]
);
@@ -450,7 +456,7 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) {
assert_eq!(
editor
- .update(cx, |editor, _, cx| editor.selections.display_ranges(cx))
+ .update(cx, |editor, _, cx| display_ranges(editor, cx))
.unwrap(),
[DisplayPoint::new(DisplayRow(2), 2)..DisplayPoint::new(DisplayRow(1), 1)]
);
@@ -468,7 +474,7 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) {
assert_eq!(
editor
- .update(cx, |editor, _, cx| editor.selections.display_ranges(cx))
+ .update(cx, |editor, _, cx| display_ranges(editor, cx))
.unwrap(),
[DisplayPoint::new(DisplayRow(2), 2)..DisplayPoint::new(DisplayRow(1), 1)]
);
@@ -486,7 +492,7 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) {
assert_eq!(
editor
- .update(cx, |editor, _, cx| editor.selections.display_ranges(cx))
+ .update(cx, |editor, _, cx| display_ranges(editor, cx))
.unwrap(),
[
DisplayPoint::new(DisplayRow(2), 2)..DisplayPoint::new(DisplayRow(1), 1),
@@ -500,7 +506,7 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) {
assert_eq!(
editor
- .update(cx, |editor, _, cx| editor.selections.display_ranges(cx))
+ .update(cx, |editor, _, cx| display_ranges(editor, cx))
.unwrap(),
[DisplayPoint::new(DisplayRow(3), 3)..DisplayPoint::new(DisplayRow(0), 0)]
);
@@ -533,7 +539,7 @@ fn test_multiple_cursor_removal(cx: &mut TestAppContext) {
assert_eq!(
editor
- .update(cx, |editor, _, cx| editor.selections.display_ranges(cx))
+ .update(cx, |editor, _, cx| display_ranges(editor, cx))
.unwrap(),
[
DisplayPoint::new(DisplayRow(2), 1)..DisplayPoint::new(DisplayRow(2), 1),
@@ -551,7 +557,7 @@ fn test_multiple_cursor_removal(cx: &mut TestAppContext) {
assert_eq!(
editor
- .update(cx, |editor, _, cx| editor.selections.display_ranges(cx))
+ .update(cx, |editor, _, cx| display_ranges(editor, cx))
.unwrap(),
[DisplayPoint::new(DisplayRow(3), 2)..DisplayPoint::new(DisplayRow(3), 2)]
);
@@ -569,7 +575,7 @@ fn test_canceling_pending_selection(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.begin_selection(DisplayPoint::new(DisplayRow(2), 2), false, 1, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(2), 2)..DisplayPoint::new(DisplayRow(2), 2)]
);
});
@@ -583,7 +589,7 @@ fn test_canceling_pending_selection(cx: &mut TestAppContext) {
cx,
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(2), 2)..DisplayPoint::new(DisplayRow(3), 3)]
);
});
@@ -598,7 +604,7 @@ fn test_canceling_pending_selection(cx: &mut TestAppContext) {
cx,
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(2), 2)..DisplayPoint::new(DisplayRow(3), 3)]
);
});
@@ -616,25 +622,25 @@ fn test_movement_actions_with_pending_selection(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.begin_selection(DisplayPoint::new(DisplayRow(2), 2), false, 1, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(2), 2)..DisplayPoint::new(DisplayRow(2), 2)]
);
editor.move_down(&Default::default(), window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(3), 2)..DisplayPoint::new(DisplayRow(3), 2)]
);
editor.begin_selection(DisplayPoint::new(DisplayRow(2), 2), false, 1, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(2), 2)..DisplayPoint::new(DisplayRow(2), 2)]
);
editor.move_up(&Default::default(), window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(1), 2)..DisplayPoint::new(DisplayRow(1), 2)]
);
});
@@ -653,14 +659,14 @@ fn test_extending_selection(cx: &mut TestAppContext) {
editor.begin_selection(DisplayPoint::new(DisplayRow(0), 5), false, 1, window, cx);
editor.end_selection(window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(0), 5)..DisplayPoint::new(DisplayRow(0), 5)]
);
editor.extend_selection(DisplayPoint::new(DisplayRow(0), 10), 1, window, cx);
editor.end_selection(window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(0), 5)..DisplayPoint::new(DisplayRow(0), 10)]
);
@@ -668,7 +674,7 @@ fn test_extending_selection(cx: &mut TestAppContext) {
editor.end_selection(window, cx);
editor.extend_selection(DisplayPoint::new(DisplayRow(0), 10), 2, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(0), 5)..DisplayPoint::new(DisplayRow(0), 11)]
);
@@ -681,7 +687,7 @@ fn test_extending_selection(cx: &mut TestAppContext) {
);
editor.end_selection(window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(0), 5)..DisplayPoint::new(DisplayRow(0), 0)]
);
@@ -690,13 +696,13 @@ fn test_extending_selection(cx: &mut TestAppContext) {
editor.begin_selection(DisplayPoint::new(DisplayRow(0), 5), true, 2, window, cx);
editor.end_selection(window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(0), 4)..DisplayPoint::new(DisplayRow(0), 7)]
);
editor.extend_selection(DisplayPoint::new(DisplayRow(0), 10), 1, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(0), 4)..DisplayPoint::new(DisplayRow(0), 11)]
);
@@ -708,7 +714,7 @@ fn test_extending_selection(cx: &mut TestAppContext) {
cx,
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(0), 4)..DisplayPoint::new(DisplayRow(0), 7)]
);
@@ -721,7 +727,7 @@ fn test_extending_selection(cx: &mut TestAppContext) {
);
editor.end_selection(window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(0), 7)..DisplayPoint::new(DisplayRow(0), 0)]
);
});
@@ -804,10 +810,14 @@ fn test_clone(cx: &mut TestAppContext) {
);
assert_set_eq!(
cloned_editor
- .update(cx, |e, _window, cx| e.selections.display_ranges(cx))
+ .update(cx, |e, _window, cx| e
+ .selections
+ .display_ranges(&e.display_snapshot(cx)))
.unwrap(),
editor
- .update(cx, |e, _, cx| e.selections.display_ranges(cx))
+ .update(cx, |e, _, cx| e
+ .selections
+ .display_ranges(&e.display_snapshot(cx)))
.unwrap()
);
}
@@ -861,7 +871,9 @@ async fn test_navigation_history(cx: &mut TestAppContext) {
editor.navigate(nav_entry.data.unwrap(), window, cx);
assert_eq!(nav_entry.item.id(), cx.entity_id());
assert_eq!(
- editor.selections.display_ranges(cx),
+ editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx)),
&[DisplayPoint::new(DisplayRow(3), 0)..DisplayPoint::new(DisplayRow(3), 0)]
);
assert!(pop_history(&mut editor, cx).is_none());
@@ -871,7 +883,9 @@ async fn test_navigation_history(cx: &mut TestAppContext) {
editor.begin_selection(DisplayPoint::new(DisplayRow(5), 0), false, 1, window, cx);
editor.end_selection(window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx)),
&[DisplayPoint::new(DisplayRow(5), 0)..DisplayPoint::new(DisplayRow(5), 0)]
);
assert!(pop_history(&mut editor, cx).is_none());
@@ -881,14 +895,18 @@ async fn test_navigation_history(cx: &mut TestAppContext) {
editor.begin_selection(DisplayPoint::new(DisplayRow(15), 0), false, 1, window, cx);
editor.end_selection(window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx)),
&[DisplayPoint::new(DisplayRow(15), 0)..DisplayPoint::new(DisplayRow(15), 0)]
);
let nav_entry = pop_history(&mut editor, cx).unwrap();
editor.navigate(nav_entry.data.unwrap(), window, cx);
assert_eq!(nav_entry.item.id(), cx.entity_id());
assert_eq!(
- editor.selections.display_ranges(cx),
+ editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx)),
&[DisplayPoint::new(DisplayRow(5), 0)..DisplayPoint::new(DisplayRow(5), 0)]
);
assert!(pop_history(&mut editor, cx).is_none());
@@ -924,7 +942,9 @@ async fn test_navigation_history(cx: &mut TestAppContext) {
cx,
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx)),
&[editor.max_point(cx)..editor.max_point(cx)]
);
assert_eq!(
@@ -967,7 +987,7 @@ fn test_cancel(cx: &mut TestAppContext) {
);
editor.end_selection(window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[
DisplayPoint::new(DisplayRow(0), 1)..DisplayPoint::new(DisplayRow(0), 3),
DisplayPoint::new(DisplayRow(3), 4)..DisplayPoint::new(DisplayRow(1), 1),
@@ -978,7 +998,7 @@ fn test_cancel(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.cancel(&Cancel, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(3), 4)..DisplayPoint::new(DisplayRow(1), 1)]
);
});
@@ -986,7 +1006,7 @@ fn test_cancel(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.cancel(&Cancel, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[DisplayPoint::new(DisplayRow(1), 1)..DisplayPoint::new(DisplayRow(1), 1)]
);
});
@@ -1447,43 +1467,43 @@ fn test_move_cursor(cx: &mut TestAppContext) {
});
_ = editor.update(cx, |editor, window, cx| {
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0)]
);
editor.move_down(&MoveDown, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(1), 0)..DisplayPoint::new(DisplayRow(1), 0)]
);
editor.move_right(&MoveRight, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(1), 4)..DisplayPoint::new(DisplayRow(1), 4)]
);
editor.move_left(&MoveLeft, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(1), 0)..DisplayPoint::new(DisplayRow(1), 0)]
);
editor.move_up(&MoveUp, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0)]
);
editor.move_to_end(&MoveToEnd, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(5), 6)..DisplayPoint::new(DisplayRow(5), 6)]
);
editor.move_to_beginning(&MoveToBeginning, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0)]
);
@@ -1494,13 +1514,13 @@ fn test_move_cursor(cx: &mut TestAppContext) {
});
editor.select_to_beginning(&SelectToBeginning, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(0), 1)..DisplayPoint::new(DisplayRow(0), 0)]
);
editor.select_to_end(&SelectToEnd, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(0), 1)..DisplayPoint::new(DisplayRow(5), 6)]
);
});
@@ -1532,94 +1552,43 @@ fn test_move_cursor_multibyte(cx: &mut TestAppContext) {
assert_eq!(editor.display_text(cx), "🟥🟧⋯🟦🟪\nab⋯e\nαβ⋯ε");
editor.move_right(&MoveRight, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(0, "🟥".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(0, "🟥".len())]);
editor.move_right(&MoveRight, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(0, "🟥🟧".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(0, "🟥🟧".len())]);
editor.move_right(&MoveRight, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(0, "🟥🟧⋯".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(0, "🟥🟧⋯".len())]);
editor.move_down(&MoveDown, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(1, "ab⋯e".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(1, "ab⋯e".len())]);
editor.move_left(&MoveLeft, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(1, "ab⋯".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(1, "ab⋯".len())]);
editor.move_left(&MoveLeft, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(1, "ab".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(1, "ab".len())]);
editor.move_left(&MoveLeft, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(1, "a".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(1, "a".len())]);
editor.move_down(&MoveDown, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(2, "α".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(2, "α".len())]);
editor.move_right(&MoveRight, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(2, "αβ".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(2, "αβ".len())]);
editor.move_right(&MoveRight, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(2, "αβ⋯".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(2, "αβ⋯".len())]);
editor.move_right(&MoveRight, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(2, "αβ⋯ε".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(2, "αβ⋯ε".len())]);
editor.move_up(&MoveUp, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(1, "ab⋯e".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(1, "ab⋯e".len())]);
editor.move_down(&MoveDown, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(2, "αβ⋯ε".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(2, "αβ⋯ε".len())]);
editor.move_up(&MoveUp, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(1, "ab⋯e".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(1, "ab⋯e".len())]);
editor.move_up(&MoveUp, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(0, "🟥🟧".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(0, "🟥🟧".len())]);
editor.move_left(&MoveLeft, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(0, "🟥".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(0, "🟥".len())]);
editor.move_left(&MoveLeft, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(0, "".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(0, "".len())]);
});
}
@@ -1639,65 +1608,35 @@ fn test_move_cursor_different_line_lengths(cx: &mut TestAppContext) {
// moving above start of document should move selection to start of document,
// but the next move down should still be at the original goal_x
editor.move_up(&MoveUp, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(0, "".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(0, "".len())]);
editor.move_down(&MoveDown, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(1, "abcd".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(1, "abcd".len())]);
editor.move_down(&MoveDown, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(2, "αβγ".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(2, "αβγ".len())]);
editor.move_down(&MoveDown, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(3, "abcd".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(3, "abcd".len())]);
editor.move_down(&MoveDown, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(4, "ⓐⓑⓒⓓⓔ".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(4, "ⓐⓑⓒⓓⓔ".len())]);
// moving past end of document should not change goal_x
editor.move_down(&MoveDown, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(5, "".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(5, "".len())]);
editor.move_down(&MoveDown, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(5, "".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(5, "".len())]);
editor.move_up(&MoveUp, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(4, "ⓐⓑⓒⓓⓔ".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(4, "ⓐⓑⓒⓓⓔ".len())]);
editor.move_up(&MoveUp, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(3, "abcd".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(3, "abcd".len())]);
editor.move_up(&MoveUp, window, cx);
- assert_eq!(
- editor.selections.display_ranges(cx),
- &[empty_range(2, "αβγ".len())]
- );
+ assert_eq!(display_ranges(editor, cx), &[empty_range(2, "αβγ".len())]);
});
}
@@ -1733,7 +1672,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.move_to_beginning_of_line(&move_to_beg, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(1), 2)..DisplayPoint::new(DisplayRow(1), 2),
@@ -1744,7 +1683,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.move_to_beginning_of_line(&move_to_beg, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(1), 0)..DisplayPoint::new(DisplayRow(1), 0),
@@ -1755,7 +1694,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.move_to_beginning_of_line(&move_to_beg, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(1), 2)..DisplayPoint::new(DisplayRow(1), 2),
@@ -1766,7 +1705,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.move_to_end_of_line(&move_to_end, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 3)..DisplayPoint::new(DisplayRow(0), 3),
DisplayPoint::new(DisplayRow(1), 5)..DisplayPoint::new(DisplayRow(1), 5),
@@ -1778,7 +1717,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.move_to_end_of_line(&move_to_end, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 3)..DisplayPoint::new(DisplayRow(0), 3),
DisplayPoint::new(DisplayRow(1), 5)..DisplayPoint::new(DisplayRow(1), 5),
@@ -1797,7 +1736,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) {
cx,
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 2)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(1), 4)..DisplayPoint::new(DisplayRow(1), 2),
@@ -1815,7 +1754,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) {
cx,
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 2)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(1), 4)..DisplayPoint::new(DisplayRow(1), 0),
@@ -1833,7 +1772,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) {
cx,
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 2)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(1), 4)..DisplayPoint::new(DisplayRow(1), 2),
@@ -1850,7 +1789,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) {
cx,
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 2)..DisplayPoint::new(DisplayRow(0), 3),
DisplayPoint::new(DisplayRow(1), 4)..DisplayPoint::new(DisplayRow(1), 5),
@@ -1862,7 +1801,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) {
editor.delete_to_end_of_line(&DeleteToEndOfLine, window, cx);
assert_eq!(editor.display_text(cx), "ab\n de");
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 2)..DisplayPoint::new(DisplayRow(0), 2),
DisplayPoint::new(DisplayRow(1), 4)..DisplayPoint::new(DisplayRow(1), 4),
@@ -1874,7 +1813,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) {
editor.delete_to_beginning_of_line(&delete_to_beg, window, cx);
assert_eq!(editor.display_text(cx), "\n");
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(1), 0)..DisplayPoint::new(DisplayRow(1), 0),
@@ -1927,14 +1866,14 @@ fn test_beginning_end_of_line_ignore_soft_wrap(cx: &mut TestAppContext) {
editor.move_to_beginning_of_line(&move_to_beg, window, cx);
assert_eq!(
vec![DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0),],
- editor.selections.display_ranges(cx)
+ display_ranges(editor, cx)
);
// Moving to the end of the line should put us at the end of the line.
editor.move_to_end_of_line(&move_to_end, window, cx);
assert_eq!(
vec![DisplayPoint::new(DisplayRow(0), 16)..DisplayPoint::new(DisplayRow(0), 16),],
- editor.selections.display_ranges(cx)
+ display_ranges(editor, cx)
);
// Now, let's assert behavior on the second line, that ended up being soft-wrapped.
@@ -1950,14 +1889,14 @@ fn test_beginning_end_of_line_ignore_soft_wrap(cx: &mut TestAppContext) {
editor.move_to_beginning_of_line(&move_to_beg, window, cx);
assert_eq!(
vec![DisplayPoint::new(DisplayRow(1), 0)..DisplayPoint::new(DisplayRow(1), 0),],
- editor.selections.display_ranges(cx)
+ display_ranges(editor, cx)
);
// Moving to the beginning of the line again should be a no-op.
editor.move_to_beginning_of_line(&move_to_beg, window, cx);
assert_eq!(
vec![DisplayPoint::new(DisplayRow(1), 0)..DisplayPoint::new(DisplayRow(1), 0),],
- editor.selections.display_ranges(cx)
+ display_ranges(editor, cx)
);
// Moving to the end of the line should put us right after the `s` that was soft-wrapped to the
@@ -1965,14 +1904,14 @@ fn test_beginning_end_of_line_ignore_soft_wrap(cx: &mut TestAppContext) {
editor.move_to_end_of_line(&move_to_end, window, cx);
assert_eq!(
vec![DisplayPoint::new(DisplayRow(2), 5)..DisplayPoint::new(DisplayRow(2), 5),],
- editor.selections.display_ranges(cx)
+ display_ranges(editor, cx)
);
// Moving to the end of the line again should be a no-op.
editor.move_to_end_of_line(&move_to_end, window, cx);
assert_eq!(
vec![DisplayPoint::new(DisplayRow(2), 5)..DisplayPoint::new(DisplayRow(2), 5),],
- editor.selections.display_ranges(cx)
+ display_ranges(editor, cx)
);
});
}
@@ -2016,7 +1955,7 @@ fn test_beginning_of_line_stop_at_indent(cx: &mut TestAppContext) {
// and the second cursor at the first non-whitespace character in the line.
editor.move_to_beginning_of_line(&move_to_beg, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(1), 2)..DisplayPoint::new(DisplayRow(1), 2),
@@ -2027,7 +1966,7 @@ fn test_beginning_of_line_stop_at_indent(cx: &mut TestAppContext) {
// and should move the second cursor to the beginning of the line.
editor.move_to_beginning_of_line(&move_to_beg, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(1), 0)..DisplayPoint::new(DisplayRow(1), 0),
@@ -2038,7 +1977,7 @@ fn test_beginning_of_line_stop_at_indent(cx: &mut TestAppContext) {
// and should move the second cursor back to the first non-whitespace character in the line.
editor.move_to_beginning_of_line(&move_to_beg, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(1), 2)..DisplayPoint::new(DisplayRow(1), 2),
@@ -2051,7 +1990,7 @@ fn test_beginning_of_line_stop_at_indent(cx: &mut TestAppContext) {
editor.move_left(&MoveLeft, window, cx);
editor.select_to_beginning_of_line(&select_to_beg, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 2)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(1), 4)..DisplayPoint::new(DisplayRow(1), 2),
@@ -2062,7 +2001,7 @@ fn test_beginning_of_line_stop_at_indent(cx: &mut TestAppContext) {
// and should select to the beginning of the line for the second cursor.
editor.select_to_beginning_of_line(&select_to_beg, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[
DisplayPoint::new(DisplayRow(0), 2)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(1), 4)..DisplayPoint::new(DisplayRow(1), 0),
@@ -2103,21 +2042,21 @@ fn test_beginning_of_line_with_cursor_between_line_start_and_indent(cx: &mut Tes
// cursor should move to line_start
editor.move_to_beginning_of_line(&move_to_beg, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0)]
);
// cursor should move to indent_start
editor.move_to_beginning_of_line(&move_to_beg, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(0), 4)..DisplayPoint::new(DisplayRow(0), 4)]
);
// cursor should move to back to line_start
editor.move_to_beginning_of_line(&move_to_beg, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0)]
);
});
@@ -2210,37 +2149,37 @@ fn test_prev_next_word_bounds_with_soft_wrap(cx: &mut TestAppContext) {
editor.move_to_next_word_end(&MoveToNextWordEnd, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(1), 9)..DisplayPoint::new(DisplayRow(1), 9)]
);
editor.move_to_next_word_end(&MoveToNextWordEnd, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(1), 14)..DisplayPoint::new(DisplayRow(1), 14)]
);
editor.move_to_next_word_end(&MoveToNextWordEnd, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(2), 4)..DisplayPoint::new(DisplayRow(2), 4)]
);
editor.move_to_next_word_end(&MoveToNextWordEnd, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(2), 8)..DisplayPoint::new(DisplayRow(2), 8)]
);
editor.move_to_previous_word_start(&MoveToPreviousWordStart, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(2), 4)..DisplayPoint::new(DisplayRow(2), 4)]
);
editor.move_to_previous_word_start(&MoveToPreviousWordStart, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(1), 14)..DisplayPoint::new(DisplayRow(1), 14)]
);
});
@@ -4487,7 +4426,7 @@ fn test_delete_line(cx: &mut TestAppContext) {
editor.delete_line(&DeleteLine, window, cx);
assert_eq!(editor.display_text(cx), "ghi");
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0),
DisplayPoint::new(DisplayRow(0), 1)..DisplayPoint::new(DisplayRow(0), 1),
@@ -4508,7 +4447,7 @@ fn test_delete_line(cx: &mut TestAppContext) {
editor.delete_line(&DeleteLine, window, cx);
assert_eq!(editor.display_text(cx), "ghi\n");
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![DisplayPoint::new(DisplayRow(0), 1)..DisplayPoint::new(DisplayRow(0), 1)]
);
});
@@ -4526,7 +4465,7 @@ fn test_delete_line(cx: &mut TestAppContext) {
editor.delete_line(&DeleteLine, window, cx);
assert_eq!(editor.display_text(cx), "\njkl\nmno");
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0)]
);
});
@@ -5685,7 +5624,7 @@ fn test_duplicate_line(cx: &mut TestAppContext) {
editor.duplicate_line_down(&DuplicateLineDown, window, cx);
assert_eq!(editor.display_text(cx), "abc\nabc\ndef\ndef\nghi\n\n");
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![
DisplayPoint::new(DisplayRow(1), 0)..DisplayPoint::new(DisplayRow(1), 1),
DisplayPoint::new(DisplayRow(1), 2)..DisplayPoint::new(DisplayRow(1), 2),
@@ -5709,7 +5648,7 @@ fn test_duplicate_line(cx: &mut TestAppContext) {
editor.duplicate_line_down(&DuplicateLineDown, window, cx);
assert_eq!(editor.display_text(cx), "abc\ndef\nghi\nabc\ndef\nghi\n");
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![
DisplayPoint::new(DisplayRow(3), 1)..DisplayPoint::new(DisplayRow(4), 1),
DisplayPoint::new(DisplayRow(4), 2)..DisplayPoint::new(DisplayRow(5), 1),
@@ -5735,7 +5674,7 @@ fn test_duplicate_line(cx: &mut TestAppContext) {
editor.duplicate_line_up(&DuplicateLineUp, window, cx);
assert_eq!(editor.display_text(cx), "abc\nabc\ndef\ndef\nghi\n\n");
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 1),
DisplayPoint::new(DisplayRow(0), 2)..DisplayPoint::new(DisplayRow(0), 2),
@@ -5759,7 +5698,7 @@ fn test_duplicate_line(cx: &mut TestAppContext) {
editor.duplicate_line_up(&DuplicateLineUp, window, cx);
assert_eq!(editor.display_text(cx), "abc\ndef\nghi\nabc\ndef\nghi\n");
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![
DisplayPoint::new(DisplayRow(0), 1)..DisplayPoint::new(DisplayRow(1), 1),
DisplayPoint::new(DisplayRow(1), 2)..DisplayPoint::new(DisplayRow(2), 1),
@@ -5781,7 +5720,7 @@ fn test_duplicate_line(cx: &mut TestAppContext) {
editor.duplicate_selection(&DuplicateSelection, window, cx);
assert_eq!(editor.display_text(cx), "abc\ndbc\ndef\ngf\nghi\n");
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![
DisplayPoint::new(DisplayRow(0), 1)..DisplayPoint::new(DisplayRow(1), 1),
DisplayPoint::new(DisplayRow(2), 2)..DisplayPoint::new(DisplayRow(3), 1),
@@ -5828,7 +5767,7 @@ fn test_move_line_up_down(cx: &mut TestAppContext) {
"aa⋯bbb\nccc⋯eeee\nggggg\n⋯i\njjjjj\nfffff"
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![
DisplayPoint::new(DisplayRow(0), 1)..DisplayPoint::new(DisplayRow(0), 1),
DisplayPoint::new(DisplayRow(2), 1)..DisplayPoint::new(DisplayRow(2), 1),
@@ -5845,7 +5784,7 @@ fn test_move_line_up_down(cx: &mut TestAppContext) {
"ccc⋯eeee\naa⋯bbb\nfffff\nggggg\n⋯i\njjjjj"
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![
DisplayPoint::new(DisplayRow(1), 1)..DisplayPoint::new(DisplayRow(1), 1),
DisplayPoint::new(DisplayRow(3), 1)..DisplayPoint::new(DisplayRow(3), 1),
@@ -5862,7 +5801,7 @@ fn test_move_line_up_down(cx: &mut TestAppContext) {
"ccc⋯eeee\nfffff\naa⋯bbb\nggggg\n⋯i\njjjjj"
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![
DisplayPoint::new(DisplayRow(2), 1)..DisplayPoint::new(DisplayRow(2), 1),
DisplayPoint::new(DisplayRow(3), 1)..DisplayPoint::new(DisplayRow(3), 1),
@@ -5879,7 +5818,7 @@ fn test_move_line_up_down(cx: &mut TestAppContext) {
"ccc⋯eeee\naa⋯bbb\nggggg\n⋯i\njjjjj\nfffff"
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![
DisplayPoint::new(DisplayRow(1), 1)..DisplayPoint::new(DisplayRow(1), 1),
DisplayPoint::new(DisplayRow(2), 1)..DisplayPoint::new(DisplayRow(2), 1),
@@ -7612,7 +7551,7 @@ fn test_select_all(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.select_all(&SelectAll, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
&[DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(2), 3)]
);
});
@@ -7637,7 +7576,7 @@ fn test_select_line(cx: &mut TestAppContext) {
});
editor.select_line(&SelectLine, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(2), 0),
DisplayPoint::new(DisplayRow(4), 0)..DisplayPoint::new(DisplayRow(5), 0),
@@ -7648,7 +7587,7 @@ fn test_select_line(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.select_line(&SelectLine, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(3), 0),
DisplayPoint::new(DisplayRow(4), 0)..DisplayPoint::new(DisplayRow(5), 5),
@@ -7659,7 +7598,7 @@ fn test_select_line(cx: &mut TestAppContext) {
_ = editor.update(cx, |editor, window, cx| {
editor.select_line(&SelectLine, window, cx);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
vec![DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(5), 5)]
);
});
@@ -7784,7 +7723,7 @@ async fn test_split_selection_into_lines_interacting_with_creases(cx: &mut TestA
"aaaaa\nbbbbb\nccccc\nddddd\neeeee\nfffff\nggggg\nhhhhh\niiiii"
);
assert_eq!(
- editor.selections.display_ranges(cx),
+ display_ranges(editor, cx),
[
DisplayPoint::new(DisplayRow(0), 5)..DisplayPoint::new(DisplayRow(0), 5),
DisplayPoint::new(DisplayRow(1), 5)..DisplayPoint::new(DisplayRow(1), 5),
@@ -8928,7 +8867,9 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut TestAppContext) {
editor.select_larger_syntax_node(&SelectLargerSyntaxNode, window, cx);
});
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
&[DisplayPoint::new(DisplayRow(5), 0)..DisplayPoint::new(DisplayRow(0), 0)]
);
@@ -8937,7 +8878,9 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut TestAppContext) {
editor.select_larger_syntax_node(&SelectLargerSyntaxNode, window, cx);
});
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
&[DisplayPoint::new(DisplayRow(5), 0)..DisplayPoint::new(DisplayRow(0), 0)]
);
@@ -1685,7 +1685,9 @@ mod tests {
assert_eq!(search_bar.active_match_index, Some(0));
search_bar.select_next_match(&SelectNextMatch, window, cx);
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
);
});
@@ -1696,7 +1698,9 @@ mod tests {
search_bar.update_in(cx, |search_bar, window, cx| {
search_bar.select_next_match(&SelectNextMatch, window, cx);
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]
);
});
@@ -1707,7 +1711,9 @@ mod tests {
search_bar.update_in(cx, |search_bar, window, cx| {
search_bar.select_next_match(&SelectNextMatch, window, cx);
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
);
});
@@ -1718,7 +1724,9 @@ mod tests {
search_bar.update_in(cx, |search_bar, window, cx| {
search_bar.select_next_match(&SelectNextMatch, window, cx);
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
);
});
@@ -1729,7 +1737,9 @@ mod tests {
search_bar.update_in(cx, |search_bar, window, cx| {
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
);
});
@@ -1740,7 +1750,9 @@ mod tests {
search_bar.update_in(cx, |search_bar, window, cx| {
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]
);
});
@@ -1751,7 +1763,9 @@ mod tests {
search_bar.update_in(cx, |search_bar, window, cx| {
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
);
});
@@ -1772,7 +1786,9 @@ mod tests {
assert_eq!(search_bar.active_match_index, Some(1));
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
);
});
@@ -1793,7 +1809,9 @@ mod tests {
assert_eq!(search_bar.active_match_index, Some(1));
search_bar.select_next_match(&SelectNextMatch, window, cx);
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]
);
});
@@ -1814,7 +1832,9 @@ mod tests {
assert_eq!(search_bar.active_match_index, Some(2));
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
);
});
@@ -1835,7 +1855,9 @@ mod tests {
assert_eq!(search_bar.active_match_index, Some(2));
search_bar.select_next_match(&SelectNextMatch, window, cx);
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
);
});
@@ -1856,7 +1878,9 @@ mod tests {
assert_eq!(search_bar.active_match_index, Some(0));
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
assert_eq!(
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
+ editor.update(cx, |editor, cx| editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))),
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
);
});
@@ -1989,7 +2013,7 @@ mod tests {
"Initially, the editor should not be focused"
);
let initial_selections = editor.update(cx, |editor, cx| {
- let initial_selections = editor.selections.display_ranges(cx);
+ let initial_selections = editor.selections.display_ranges(&editor.display_snapshot(cx));
assert_eq!(
initial_selections.len(), 1,
"Expected to have only one selection before adding carets to all matches, but got: {initial_selections:?}",
@@ -2008,7 +2032,7 @@ mod tests {
);
search_bar.update(cx, |search_bar, cx| {
let all_selections =
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
+ editor.update(cx, |editor, cx| editor.selections.display_ranges(&editor.display_snapshot(cx)));
assert_eq!(
all_selections.len(),
expected_query_matches_count,
@@ -2032,8 +2056,11 @@ mod tests {
"Should still have editor focused after SelectNextMatch"
);
search_bar.update(cx, |search_bar, cx| {
- let all_selections =
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
+ let all_selections = editor.update(cx, |editor, cx| {
+ editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))
+ });
assert_eq!(
all_selections.len(),
1,
@@ -2062,7 +2089,7 @@ mod tests {
);
search_bar.update(cx, |search_bar, cx| {
let all_selections =
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
+ editor.update(cx, |editor, cx| editor.selections.display_ranges(&editor.display_snapshot(cx)));
assert_eq!(
all_selections.len(),
expected_query_matches_count,
@@ -2087,8 +2114,11 @@ mod tests {
);
search_bar.update(cx, |search_bar, cx| {
- let all_selections =
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
+ let all_selections = editor.update(cx, |editor, cx| {
+ editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))
+ });
assert_eq!(
all_selections.len(),
1,
@@ -2130,7 +2160,7 @@ mod tests {
);
search_bar.update(cx, |search_bar, cx| {
let all_selections =
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
+ editor.update(cx, |editor, cx| editor.selections.display_ranges(&editor.display_snapshot(cx)));
assert_eq!(
all_selections, last_match_selections,
"Should not select anything new if there are no matches"
@@ -2194,8 +2224,11 @@ mod tests {
search_bar.select_all_matches(&SelectAllMatches, window, cx);
});
search_bar.update(cx, |_, cx| {
- let all_selections =
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
+ let all_selections = editor.update(cx, |editor, cx| {
+ editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))
+ });
assert_eq!(
all_selections.len(),
2,
@@ -2220,8 +2253,11 @@ mod tests {
search_bar.select_all_matches(&SelectAllMatches, window, cx);
});
search_bar.update(cx, |_, cx| {
- let all_selections =
- editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
+ let all_selections = editor.update(cx, |editor, cx| {
+ editor
+ .selections
+ .display_ranges(&editor.display_snapshot(cx))
+ });
assert_eq!(
all_selections.len(),
2,