History

sum_tree: Replace rayon with futures (#41586)

Release Notes: - N/A *or* Added/Fixed/Improved ... Co-authored by: Kate <kate@zed.dev>

Lukas Wirth committed 1 year ago

Commit f2ce06c1 parent 7c29c6d67 files · +1271 −640Browse files

Showing the changes to crates/multi_buffer/src (1 of 67 files). Show all

Unified · Split

crates/multi_buffer/src/multi_buffer_tests.rs+19−14
@@ -1,6 +1,6 @@
11 use super::*;
22 use buffer_diff::{DiffHunkStatus, DiffHunkStatusKind};
3−use gpui::{App, TestAppContext};
3+use gpui::{App, BackgroundExecutor, TestAppContext};
44 use indoc::indoc;
55 use language::{Buffer, Rope};
66 use parking_lot::RwLock;
@@ -79,9 +79,14 @@ fn test_remote(cx: &mut App) { · 72 unmodified lines
7979 let ops = cx
8080 .background_executor()
8181 .block(host_buffer.read(cx).serialize_ops(None, cx));
82− let mut buffer =
83− Buffer::from_proto(ReplicaId::REMOTE_SERVER, Capability::ReadWrite, state, None)
84− .unwrap();
82+ let mut buffer = Buffer::from_proto(
83+ ReplicaId::REMOTE_SERVER,
84+ Capability::ReadWrite,
85+ state,
86+ None,
87+ cx.background_executor(),
88+ )
89+ .unwrap();
8590 buffer.apply_ops(
8691 ops.into_iter()
8792 .map(|op| language::proto::deserialize_operation(op).unwrap()),
@@ -1224,7 +1229,7 @@ fn test_basic_diff_hunks(cx: &mut TestAppContext) { · 1136 unmodified lines
12241229 assert_chunks_in_ranges(&snapshot);
12251230 assert_consistent_line_numbers(&snapshot);
12261231 assert_position_translation(&snapshot);
1227− assert_line_indents(&snapshot);
1232+ assert_line_indents(&snapshot, cx.background_executor());
12281233
12291234 multibuffer.update(cx, |multibuffer, cx| {
12301235 multibuffer.collapse_diff_hunks(vec![Anchor::min()..Anchor::max()], cx)
@@ -1248,7 +1253,7 @@ fn test_basic_diff_hunks(cx: &mut TestAppContext) { · 17 unmodified lines
12481253 assert_chunks_in_ranges(&snapshot);
12491254 assert_consistent_line_numbers(&snapshot);
12501255 assert_position_translation(&snapshot);
1251− assert_line_indents(&snapshot);
1256+ assert_line_indents(&snapshot, cx.background_executor());
12521257
12531258 // Expand the first diff hunk
12541259 multibuffer.update(cx, |multibuffer, cx| {
@@ -1300,7 +1305,7 @@ fn test_basic_diff_hunks(cx: &mut TestAppContext) { · 45 unmodified lines
13001305 assert_chunks_in_ranges(&snapshot);
13011306 assert_consistent_line_numbers(&snapshot);
13021307 assert_position_translation(&snapshot);
1303− assert_line_indents(&snapshot);
1308+ assert_line_indents(&snapshot, cx.background_executor());
13041309
13051310 // Edit the buffer before the first hunk
13061311 buffer.update(cx, |buffer, cx| {
@@ -1342,7 +1347,7 @@ fn test_basic_diff_hunks(cx: &mut TestAppContext) { · 35 unmodified lines
13421347 assert_chunks_in_ranges(&snapshot);
13431348 assert_consistent_line_numbers(&snapshot);
13441349 assert_position_translation(&snapshot);
1345− assert_line_indents(&snapshot);
1350+ assert_line_indents(&snapshot, cx.background_executor());
13461351
13471352 // Recalculate the diff, changing the first diff hunk.
13481353 diff.update(cx, |diff, cx| {
@@ -2067,7 +2072,7 @@ fn test_diff_hunks_with_multiple_excerpts(cx: &mut TestAppContext) { · 718 unmodified lines
20672072 }
20682073
20692074 assert_position_translation(&snapshot);
2070− assert_line_indents(&snapshot);
2075+ assert_line_indents(&snapshot, cx.background_executor());
20712076
20722077 assert_eq!(
20732078 snapshot
@@ -2118,7 +2123,7 @@ fn test_diff_hunks_with_multiple_excerpts(cx: &mut TestAppContext) { · 44 unmodified lines
21182123 ),
21192124 );
21202125
2121− assert_line_indents(&snapshot);
2126+ assert_line_indents(&snapshot, cx.background_executor());
21222127 }
21232128
21242129 /// A naive implementation of a multi-buffer that does not maintain
@@ -2888,7 +2893,7 @@ async fn test_random_multibuffer(cx: &mut TestAppContext, mut rng: StdRng) { · 763 unmodified lines
28882893 );
28892894 }
28902895
2891− let text_rope = Rope::from(expected_text.as_str());
2896+ let text_rope = Rope::from_str(expected_text.as_str(), cx.background_executor());
28922897 for _ in 0..10 {
28932898 let end_ix = text_rope.clip_offset(rng.random_range(0..=text_rope.len()), Bias::Right);
28942899 let start_ix = text_rope.clip_offset(rng.random_range(0..=end_ix), Bias::Left);
@@ -3512,7 +3517,7 @@ fn assert_consistent_line_numbers(snapshot: &MultiBufferSnapshot) { · 617 unmodified lines
35123517
35133518 #[track_caller]
35143519 fn assert_position_translation(snapshot: &MultiBufferSnapshot) {
3515− let text = Rope::from(snapshot.text());
3520+ let text = Rope::from_str_small(&snapshot.text());
35163521
35173522 let mut left_anchors = Vec::new();
35183523 let mut right_anchors = Vec::new();
@@ -3636,10 +3641,10 @@ fn assert_position_translation(snapshot: &MultiBufferSnapshot) { · 117 unmodified lines
36363641 }
36373642 }
36383643
3639−fn assert_line_indents(snapshot: &MultiBufferSnapshot) {
3644+fn assert_line_indents(snapshot: &MultiBufferSnapshot, executor: &BackgroundExecutor) {
36403645 let max_row = snapshot.max_point().row;
36413646 let buffer_id = snapshot.excerpts().next().unwrap().1.remote_id();
3642− let text = text::Buffer::new(ReplicaId::LOCAL, buffer_id, snapshot.text());
3647+ let text = text::Buffer::new(ReplicaId::LOCAL, buffer_id, snapshot.text(), executor);
36433648 let mut line_indents = text
36443649 .line_indents_in_row_range(0..max_row + 1)
36453650 .collect::<Vec<_>>();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t