multi_buffer: Typed MultiBufferOffset (#42707)
This PR introduces a new `MultiBufferOffset` new type wrapping size. The goal of this is to make it clear at the type level when we are interacting with offsets of a multi buffer versus offsets of a language / text buffer. This improves readability of things quite a bit by making it clear what kind of offsets one is working with while also reducing accidental bugs by using the wrong kin of offset for the wrong API. This PR also uncovered two minor bugs due to that. Does not yet introduce the MultiBufferPoint equivalent, that is for a follow up PR. Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -7,7 +7,7 @@ use channel::ACKNOWLEDGE_DEBOUNCE_INTERVAL;
|
||||
use client::{Collaborator, ParticipantIndex, UserId};
|
||||
use collab_ui::channel_view::ChannelView;
|
||||
use collections::HashMap;
|
||||
use editor::{Anchor, Editor, ToOffset};
|
||||
use editor::{Anchor, Editor, MultiBufferOffset, ToOffset};
|
||||
use futures::future;
|
||||
use gpui::{BackgroundExecutor, Context, Entity, TestAppContext, Window};
|
||||
use rpc::{RECEIVE_TIMEOUT, proto::PeerId};
|
||||
@@ -180,7 +180,7 @@ async fn test_channel_notes_participant_indices(
|
||||
notes.editor.update(cx, |editor, cx| {
|
||||
editor.insert("a", window, cx);
|
||||
editor.change_selections(Default::default(), window, cx, |selections| {
|
||||
selections.select_ranges(vec![0..1]);
|
||||
selections.select_ranges(vec![MultiBufferOffset(0)..MultiBufferOffset(1)]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -190,7 +190,7 @@ async fn test_channel_notes_participant_indices(
|
||||
editor.move_down(&Default::default(), window, cx);
|
||||
editor.insert("b", window, cx);
|
||||
editor.change_selections(Default::default(), window, cx, |selections| {
|
||||
selections.select_ranges(vec![1..2]);
|
||||
selections.select_ranges(vec![MultiBufferOffset(1)..MultiBufferOffset(2)]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -200,7 +200,7 @@ async fn test_channel_notes_participant_indices(
|
||||
editor.move_down(&Default::default(), window, cx);
|
||||
editor.insert("c", window, cx);
|
||||
editor.change_selections(Default::default(), window, cx, |selections| {
|
||||
selections.select_ranges(vec![2..3]);
|
||||
selections.select_ranges(vec![MultiBufferOffset(2)..MultiBufferOffset(3)]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -287,12 +287,12 @@ async fn test_channel_notes_participant_indices(
|
||||
|
||||
editor_a.update_in(cx_a, |editor, window, cx| {
|
||||
editor.change_selections(Default::default(), window, cx, |selections| {
|
||||
selections.select_ranges(vec![0..1]);
|
||||
selections.select_ranges(vec![MultiBufferOffset(0)..MultiBufferOffset(1)]);
|
||||
});
|
||||
});
|
||||
editor_b.update_in(cx_b, |editor, window, cx| {
|
||||
editor.change_selections(Default::default(), window, cx, |selections| {
|
||||
selections.select_ranges(vec![2..3]);
|
||||
selections.select_ranges(vec![MultiBufferOffset(2)..MultiBufferOffset(3)]);
|
||||
});
|
||||
});
|
||||
executor.run_until_parked();
|
||||
@@ -327,7 +327,7 @@ fn assert_remote_selections(
|
||||
let end = s.selection.end.to_offset(snapshot.buffer_snapshot());
|
||||
let user_id = collaborators.get(&peer_id).unwrap().user_id;
|
||||
let participant_index = hub.user_participant_indices(cx).get(&user_id).copied();
|
||||
(participant_index, start..end)
|
||||
(participant_index, start.0..end.0)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
|
||||
@@ -4,7 +4,8 @@ use crate::{
|
||||
};
|
||||
use call::ActiveCall;
|
||||
use editor::{
|
||||
DocumentColorsRenderMode, Editor, FETCH_COLORS_DEBOUNCE_TIMEOUT, RowInfo, SelectionEffects,
|
||||
DocumentColorsRenderMode, Editor, FETCH_COLORS_DEBOUNCE_TIMEOUT, MultiBufferOffset, RowInfo,
|
||||
SelectionEffects,
|
||||
actions::{
|
||||
ConfirmCodeAction, ConfirmCompletion, ConfirmRename, ContextMenuFirst,
|
||||
ExpandMacroRecursively, MoveToEnd, Redo, Rename, SelectAll, ToggleCodeActions, Undo,
|
||||
@@ -381,7 +382,7 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu
|
||||
// Type a completion trigger character as the guest.
|
||||
editor_b.update_in(cx_b, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([13..13])
|
||||
s.select_ranges([MultiBufferOffset(13)..MultiBufferOffset(13)])
|
||||
});
|
||||
editor.handle_input(".", window, cx);
|
||||
});
|
||||
@@ -503,7 +504,7 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu
|
||||
// resolved
|
||||
editor_b.update_in(cx_b, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([46..46])
|
||||
s.select_ranges([MultiBufferOffset(46)..MultiBufferOffset(46)])
|
||||
});
|
||||
editor.handle_input("; a", window, cx);
|
||||
editor.handle_input(".", window, cx);
|
||||
@@ -601,7 +602,7 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu
|
||||
// Add another completion trigger to test the second language server
|
||||
editor_b.update_in(cx_b, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([68..68])
|
||||
s.select_ranges([MultiBufferOffset(68)..MultiBufferOffset(68)])
|
||||
});
|
||||
editor.handle_input("; b", window, cx);
|
||||
editor.handle_input(".", window, cx);
|
||||
@@ -950,7 +951,7 @@ async fn test_collaborating_with_renames(cx_a: &mut TestAppContext, cx_b: &mut T
|
||||
// Move cursor to a location that can be renamed.
|
||||
let prepare_rename = editor_b.update_in(cx_b, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([7..7])
|
||||
s.select_ranges([MultiBufferOffset(7)..MultiBufferOffset(7)])
|
||||
});
|
||||
editor.rename(&Rename, window, cx).unwrap()
|
||||
});
|
||||
@@ -977,17 +978,17 @@ async fn test_collaborating_with_renames(cx_a: &mut TestAppContext, cx_b: &mut T
|
||||
let buffer = editor.buffer().read(cx).snapshot(cx);
|
||||
assert_eq!(
|
||||
rename.range.start.to_offset(&buffer)..rename.range.end.to_offset(&buffer),
|
||||
6..9
|
||||
MultiBufferOffset(6)..MultiBufferOffset(9)
|
||||
);
|
||||
rename.editor.update(cx, |rename_editor, cx| {
|
||||
let rename_selection = rename_editor.selections.newest::<usize>(&rename_editor.display_snapshot(cx));
|
||||
let rename_selection = rename_editor.selections.newest::<MultiBufferOffset>(&rename_editor.display_snapshot(cx));
|
||||
assert_eq!(
|
||||
rename_selection.range(),
|
||||
0..3,
|
||||
MultiBufferOffset(0)..MultiBufferOffset(3),
|
||||
"Rename that was triggered from zero selection caret, should propose the whole word."
|
||||
);
|
||||
rename_editor.buffer().update(cx, |rename_buffer, cx| {
|
||||
rename_buffer.edit([(0..3, "THREE")], None, cx);
|
||||
rename_buffer.edit([(MultiBufferOffset(0)..MultiBufferOffset(3), "THREE")], None, cx);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -998,7 +999,7 @@ async fn test_collaborating_with_renames(cx_a: &mut TestAppContext, cx_b: &mut T
|
||||
});
|
||||
let prepare_rename = editor_b.update_in(cx_b, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([7..8])
|
||||
s.select_ranges([MultiBufferOffset(7)..MultiBufferOffset(8)])
|
||||
});
|
||||
editor.rename(&Rename, window, cx).unwrap()
|
||||
});
|
||||
@@ -1025,16 +1026,16 @@ async fn test_collaborating_with_renames(cx_a: &mut TestAppContext, cx_b: &mut T
|
||||
let buffer = editor.buffer().read(cx).snapshot(cx);
|
||||
let lsp_rename_start = rename.range.start.to_offset(&buffer);
|
||||
let lsp_rename_end = rename.range.end.to_offset(&buffer);
|
||||
assert_eq!(lsp_rename_start..lsp_rename_end, 6..9);
|
||||
assert_eq!(lsp_rename_start..lsp_rename_end, MultiBufferOffset(6)..MultiBufferOffset(9));
|
||||
rename.editor.update(cx, |rename_editor, cx| {
|
||||
let rename_selection = rename_editor.selections.newest::<usize>(&rename_editor.display_snapshot(cx));
|
||||
let rename_selection = rename_editor.selections.newest::<MultiBufferOffset>(&rename_editor.display_snapshot(cx));
|
||||
assert_eq!(
|
||||
rename_selection.range(),
|
||||
1..2,
|
||||
MultiBufferOffset(1)..MultiBufferOffset(2),
|
||||
"Rename that was triggered from a selection, should have the same selection range in the rename proposal"
|
||||
);
|
||||
rename_editor.buffer().update(cx, |rename_buffer, cx| {
|
||||
rename_buffer.edit([(0..lsp_rename_end - lsp_rename_start, "THREE")], None, cx);
|
||||
rename_buffer.edit([(MultiBufferOffset(0)..MultiBufferOffset(lsp_rename_end - lsp_rename_start), "THREE")], None, cx);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1237,7 +1238,7 @@ async fn test_slow_lsp_server(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
|
||||
// Move cursor to a location, this should trigger the code lens call.
|
||||
editor_b.update_in(cx_b, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([7..7])
|
||||
s.select_ranges([MultiBufferOffset(7)..MultiBufferOffset(7)])
|
||||
});
|
||||
});
|
||||
let () = request_started_rx.next().await.unwrap();
|
||||
@@ -1259,7 +1260,7 @@ async fn test_slow_lsp_server(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
|
||||
|
||||
editor_b.update_in(cx_b, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([1..1])
|
||||
s.select_ranges([MultiBufferOffset(1)..MultiBufferOffset(1)])
|
||||
});
|
||||
});
|
||||
let () = request_started_rx.next().await.unwrap();
|
||||
@@ -1281,7 +1282,7 @@ async fn test_slow_lsp_server(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
|
||||
|
||||
editor_b.update_in(cx_b, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([2..2])
|
||||
s.select_ranges([MultiBufferOffset(2)..MultiBufferOffset(2)])
|
||||
});
|
||||
});
|
||||
let () = request_started_rx.next().await.unwrap();
|
||||
@@ -1719,7 +1720,7 @@ async fn test_on_input_format_from_host_to_guest(
|
||||
cx_a.focus(&editor_a);
|
||||
editor_a.update_in(cx_a, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([13..13])
|
||||
s.select_ranges([MultiBufferOffset(13)..MultiBufferOffset(13)])
|
||||
});
|
||||
editor.handle_input(">", window, cx);
|
||||
});
|
||||
@@ -1828,7 +1829,7 @@ async fn test_on_input_format_from_guest_to_host(
|
||||
cx_b.focus(&editor_b);
|
||||
editor_b.update_in(cx_b, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([13..13])
|
||||
s.select_ranges([MultiBufferOffset(13)..MultiBufferOffset(13)])
|
||||
});
|
||||
editor.handle_input(":", window, cx);
|
||||
});
|
||||
@@ -2056,7 +2057,7 @@ async fn test_mutual_editor_inlay_hint_cache_update(
|
||||
let after_client_edit = edits_made.fetch_add(1, atomic::Ordering::Release) + 1;
|
||||
editor_b.update_in(cx_b, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([13..13].clone())
|
||||
s.select_ranges([MultiBufferOffset(13)..MultiBufferOffset(13)].clone())
|
||||
});
|
||||
editor.handle_input(":", window, cx);
|
||||
});
|
||||
@@ -2080,7 +2081,7 @@ async fn test_mutual_editor_inlay_hint_cache_update(
|
||||
let after_host_edit = edits_made.fetch_add(1, atomic::Ordering::Release) + 1;
|
||||
editor_a.update_in(cx_a, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([13..13])
|
||||
s.select_ranges([MultiBufferOffset(13)..MultiBufferOffset(13)])
|
||||
});
|
||||
editor.handle_input("a change to increment both buffers' versions", window, cx);
|
||||
});
|
||||
@@ -2520,7 +2521,7 @@ async fn test_lsp_document_color(cx_a: &mut TestAppContext, cx_b: &mut TestAppCo
|
||||
|
||||
editor_a.update_in(cx_a, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([13..13].clone())
|
||||
s.select_ranges([MultiBufferOffset(13)..MultiBufferOffset(13)].clone())
|
||||
});
|
||||
editor.handle_input(":", window, cx);
|
||||
});
|
||||
@@ -2957,7 +2958,7 @@ async fn test_lsp_pull_diagnostics(
|
||||
editor_a_main.update(cx_a, |editor, cx| {
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let all_diagnostics = snapshot
|
||||
.diagnostics_in_range(0..snapshot.len())
|
||||
.diagnostics_in_range(MultiBufferOffset(0)..snapshot.len())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
all_diagnostics.len(),
|
||||
@@ -3086,7 +3087,7 @@ async fn test_lsp_pull_diagnostics(
|
||||
editor_a_main.update(cx_a, |editor, cx| {
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let all_diagnostics = snapshot
|
||||
.diagnostics_in_range(0..snapshot.len())
|
||||
.diagnostics_in_range(MultiBufferOffset(0)..snapshot.len())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
all_diagnostics.len(),
|
||||
@@ -3133,7 +3134,7 @@ async fn test_lsp_pull_diagnostics(
|
||||
editor_b_main.update(cx_b, |editor, cx| {
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let all_diagnostics = snapshot
|
||||
.diagnostics_in_range(0..snapshot.len())
|
||||
.diagnostics_in_range(MultiBufferOffset(0)..snapshot.len())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
all_diagnostics.len(),
|
||||
@@ -3180,7 +3181,7 @@ async fn test_lsp_pull_diagnostics(
|
||||
editor_b_lib.update(cx_b, |editor, cx| {
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let all_diagnostics = snapshot
|
||||
.diagnostics_in_range(0..snapshot.len())
|
||||
.diagnostics_in_range(MultiBufferOffset(0)..snapshot.len())
|
||||
.collect::<Vec<_>>();
|
||||
let expected_messages = [
|
||||
expected_pull_diagnostic_lib_message,
|
||||
@@ -3247,7 +3248,7 @@ async fn test_lsp_pull_diagnostics(
|
||||
editor_b_lib.update(cx_b, |editor, cx| {
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let all_diagnostics = snapshot
|
||||
.diagnostics_in_range(0..snapshot.len())
|
||||
.diagnostics_in_range(MultiBufferOffset(0)..snapshot.len())
|
||||
.collect::<Vec<_>>();
|
||||
let expected_messages = [
|
||||
expected_workspace_pull_diagnostics_lib_message,
|
||||
@@ -3382,7 +3383,7 @@ async fn test_lsp_pull_diagnostics(
|
||||
editor_b_lib.update(cx_b, |editor, cx| {
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let all_diagnostics = snapshot
|
||||
.diagnostics_in_range(0..snapshot.len())
|
||||
.diagnostics_in_range(MultiBufferOffset(0)..snapshot.len())
|
||||
.collect::<Vec<_>>();
|
||||
let expected_messages = [
|
||||
expected_workspace_pull_diagnostics_lib_message,
|
||||
@@ -3400,7 +3401,7 @@ async fn test_lsp_pull_diagnostics(
|
||||
editor_b_main.update(cx_b, |editor, cx| {
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let all_diagnostics = snapshot
|
||||
.diagnostics_in_range(0..snapshot.len())
|
||||
.diagnostics_in_range(MultiBufferOffset(0)..snapshot.len())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(all_diagnostics.len(), 2);
|
||||
|
||||
@@ -3419,7 +3420,7 @@ async fn test_lsp_pull_diagnostics(
|
||||
editor_a_main.update(cx_a, |editor, cx| {
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let all_diagnostics = snapshot
|
||||
.diagnostics_in_range(0..snapshot.len())
|
||||
.diagnostics_in_range(MultiBufferOffset(0)..snapshot.len())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(all_diagnostics.len(), 2);
|
||||
let expected_messages = [
|
||||
|
||||
@@ -6,7 +6,7 @@ use collab_ui::{
|
||||
channel_view::ChannelView,
|
||||
notifications::project_shared_notification::ProjectSharedNotification,
|
||||
};
|
||||
use editor::{Editor, MultiBuffer, PathKey, SelectionEffects};
|
||||
use editor::{Editor, MultiBuffer, MultiBufferOffset, PathKey, SelectionEffects};
|
||||
use gpui::{
|
||||
AppContext as _, BackgroundExecutor, BorrowAppContext, Entity, SharedString, TestAppContext,
|
||||
VisualContext, VisualTestContext, point,
|
||||
@@ -124,7 +124,7 @@ async fn test_basic_following(
|
||||
editor.select_left(&Default::default(), window, cx);
|
||||
assert_eq!(
|
||||
editor.selections.ranges(&editor.display_snapshot(cx)),
|
||||
vec![3..2]
|
||||
vec![MultiBufferOffset(3)..MultiBufferOffset(2)]
|
||||
);
|
||||
});
|
||||
editor_a2.update_in(cx_a, |editor, window, cx| {
|
||||
@@ -133,7 +133,7 @@ async fn test_basic_following(
|
||||
editor.select_left(&Default::default(), window, cx);
|
||||
assert_eq!(
|
||||
editor.selections.ranges(&editor.display_snapshot(cx)),
|
||||
vec![2..1]
|
||||
vec![MultiBufferOffset(2)..MultiBufferOffset(1)]
|
||||
);
|
||||
});
|
||||
|
||||
@@ -158,13 +158,13 @@ async fn test_basic_following(
|
||||
editor_b2.update(cx_b, |editor, cx| editor
|
||||
.selections
|
||||
.ranges(&editor.display_snapshot(cx))),
|
||||
vec![2..1]
|
||||
vec![MultiBufferOffset(2)..MultiBufferOffset(1)]
|
||||
);
|
||||
assert_eq!(
|
||||
editor_b1.update(cx_b, |editor, cx| editor
|
||||
.selections
|
||||
.ranges(&editor.display_snapshot(cx))),
|
||||
vec![3..3]
|
||||
vec![MultiBufferOffset(3)..MultiBufferOffset(3)]
|
||||
);
|
||||
|
||||
executor.run_until_parked();
|
||||
@@ -386,7 +386,10 @@ async fn test_basic_following(
|
||||
// Changes to client A's editor are reflected on client B.
|
||||
editor_a1.update_in(cx_a, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([1..1, 2..2])
|
||||
s.select_ranges([
|
||||
MultiBufferOffset(1)..MultiBufferOffset(1),
|
||||
MultiBufferOffset(2)..MultiBufferOffset(2),
|
||||
])
|
||||
});
|
||||
});
|
||||
executor.advance_clock(workspace::item::LEADER_UPDATE_THROTTLE);
|
||||
@@ -396,7 +399,10 @@ async fn test_basic_following(
|
||||
editor_b1.update(cx_b, |editor, cx| {
|
||||
assert_eq!(
|
||||
editor.selections.ranges(&editor.display_snapshot(cx)),
|
||||
&[1..1, 2..2]
|
||||
&[
|
||||
MultiBufferOffset(1)..MultiBufferOffset(1),
|
||||
MultiBufferOffset(2)..MultiBufferOffset(2)
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
@@ -408,7 +414,7 @@ async fn test_basic_following(
|
||||
|
||||
editor_a1.update_in(cx_a, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([3..3])
|
||||
s.select_ranges([MultiBufferOffset(3)..MultiBufferOffset(3)])
|
||||
});
|
||||
editor.set_scroll_position(point(0., 100.), window, cx);
|
||||
});
|
||||
@@ -417,7 +423,7 @@ async fn test_basic_following(
|
||||
editor_b1.update(cx_b, |editor, cx| {
|
||||
assert_eq!(
|
||||
editor.selections.ranges(&editor.display_snapshot(cx)),
|
||||
&[3..3]
|
||||
&[MultiBufferOffset(3)..MultiBufferOffset(3)]
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1694,7 +1700,7 @@ async fn test_following_stops_on_unshare(cx_a: &mut TestAppContext, cx_b: &mut T
|
||||
// b should follow a to position 1
|
||||
editor_a.update_in(cx_a, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([1..1])
|
||||
s.select_ranges([MultiBufferOffset(1)..MultiBufferOffset(1)])
|
||||
})
|
||||
});
|
||||
cx_a.executor()
|
||||
@@ -1703,7 +1709,7 @@ async fn test_following_stops_on_unshare(cx_a: &mut TestAppContext, cx_b: &mut T
|
||||
editor_b.update(cx_b, |editor, cx| {
|
||||
assert_eq!(
|
||||
editor.selections.ranges(&editor.display_snapshot(cx)),
|
||||
vec![1..1]
|
||||
vec![MultiBufferOffset(1)..MultiBufferOffset(1)]
|
||||
)
|
||||
});
|
||||
|
||||
@@ -1719,7 +1725,7 @@ async fn test_following_stops_on_unshare(cx_a: &mut TestAppContext, cx_b: &mut T
|
||||
// b should not follow a to position 2
|
||||
editor_a.update_in(cx_a, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([2..2])
|
||||
s.select_ranges([MultiBufferOffset(2)..MultiBufferOffset(2)])
|
||||
})
|
||||
});
|
||||
cx_a.executor()
|
||||
@@ -1728,7 +1734,7 @@ async fn test_following_stops_on_unshare(cx_a: &mut TestAppContext, cx_b: &mut T
|
||||
editor_b.update(cx_b, |editor, cx| {
|
||||
assert_eq!(
|
||||
editor.selections.ranges(&editor.display_snapshot(cx)),
|
||||
vec![1..1]
|
||||
vec![MultiBufferOffset(1)..MultiBufferOffset(1)]
|
||||
)
|
||||
});
|
||||
cx_b.update(|_, cx| {
|
||||
@@ -1829,7 +1835,7 @@ async fn test_following_into_excluded_file(
|
||||
editor.select_left(&Default::default(), window, cx);
|
||||
assert_eq!(
|
||||
editor.selections.ranges(&editor.display_snapshot(cx)),
|
||||
vec![3..2]
|
||||
vec![MultiBufferOffset(3)..MultiBufferOffset(2)]
|
||||
);
|
||||
});
|
||||
editor_for_excluded_a.update_in(cx_a, |editor, window, cx| {
|
||||
@@ -1838,7 +1844,7 @@ async fn test_following_into_excluded_file(
|
||||
editor.select_left(&Default::default(), window, cx);
|
||||
assert_eq!(
|
||||
editor.selections.ranges(&editor.display_snapshot(cx)),
|
||||
vec![18..17]
|
||||
vec![MultiBufferOffset(18)..MultiBufferOffset(17)]
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1864,7 +1870,7 @@ async fn test_following_into_excluded_file(
|
||||
editor_for_excluded_b.update(cx_b, |editor, cx| editor
|
||||
.selections
|
||||
.ranges(&editor.display_snapshot(cx))),
|
||||
vec![18..17]
|
||||
vec![MultiBufferOffset(18)..MultiBufferOffset(17)]
|
||||
);
|
||||
|
||||
editor_for_excluded_a.update_in(cx_a, |editor, window, cx| {
|
||||
@@ -2040,7 +2046,7 @@ async fn test_following_to_channel_notes_without_a_shared_project(
|
||||
notes.editor.update(cx, |editor, cx| {
|
||||
editor.insert("Hello from A.", window, cx);
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |selections| {
|
||||
selections.select_ranges(vec![3..4]);
|
||||
selections.select_ranges(vec![MultiBufferOffset(3)..MultiBufferOffset(4)]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -2076,8 +2082,8 @@ async fn test_following_to_channel_notes_without_a_shared_project(
|
||||
assert_eq!(
|
||||
editor
|
||||
.selections
|
||||
.ranges::<usize>(&editor.display_snapshot(cx)),
|
||||
&[3..4]
|
||||
.ranges::<MultiBufferOffset>(&editor.display_snapshot(cx)),
|
||||
&[MultiBufferOffset(3)..MultiBufferOffset(4)]
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user