Release Notes: - N/A *or* Added/Fixed/Improved ... Co-authored by: Kate <kate@zed.dev>
Showing the changes to crates/multi_buffer/src (1 of 67 files). Show all
Unified · Split
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | use super::*; |
| 2 | 2 | use buffer_diff::{DiffHunkStatus, DiffHunkStatusKind}; |
| 3 | −use gpui::{App, TestAppContext}; | |
| 3 | +use gpui::{App, BackgroundExecutor, TestAppContext}; | |
| 4 | 4 | use indoc::indoc; |
| 5 | 5 | use language::{Buffer, Rope}; |
| 6 | 6 | use parking_lot::RwLock; |
| @@ -79,9 +79,14 @@ fn test_remote(cx: &mut App) { · 72 unmodified lines | ||
| 79 | 79 | let ops = cx |
| 80 | 80 | .background_executor() |
| 81 | 81 | .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(); | |
| 85 | 90 | buffer.apply_ops( |
| 86 | 91 | ops.into_iter() |
| 87 | 92 | .map(|op| language::proto::deserialize_operation(op).unwrap()), |
| @@ -1224,7 +1229,7 @@ fn test_basic_diff_hunks(cx: &mut TestAppContext) { · 1136 unmodified lines | ||
| 1224 | 1229 | assert_chunks_in_ranges(&snapshot); |
| 1225 | 1230 | assert_consistent_line_numbers(&snapshot); |
| 1226 | 1231 | assert_position_translation(&snapshot); |
| 1227 | − assert_line_indents(&snapshot); | |
| 1232 | + assert_line_indents(&snapshot, cx.background_executor()); | |
| 1228 | 1233 | |
| 1229 | 1234 | multibuffer.update(cx, |multibuffer, cx| { |
| 1230 | 1235 | 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 | ||
| 1248 | 1253 | assert_chunks_in_ranges(&snapshot); |
| 1249 | 1254 | assert_consistent_line_numbers(&snapshot); |
| 1250 | 1255 | assert_position_translation(&snapshot); |
| 1251 | − assert_line_indents(&snapshot); | |
| 1256 | + assert_line_indents(&snapshot, cx.background_executor()); | |
| 1252 | 1257 | |
| 1253 | 1258 | // Expand the first diff hunk |
| 1254 | 1259 | multibuffer.update(cx, |multibuffer, cx| { |
| @@ -1300,7 +1305,7 @@ fn test_basic_diff_hunks(cx: &mut TestAppContext) { · 45 unmodified lines | ||
| 1300 | 1305 | assert_chunks_in_ranges(&snapshot); |
| 1301 | 1306 | assert_consistent_line_numbers(&snapshot); |
| 1302 | 1307 | assert_position_translation(&snapshot); |
| 1303 | − assert_line_indents(&snapshot); | |
| 1308 | + assert_line_indents(&snapshot, cx.background_executor()); | |
| 1304 | 1309 | |
| 1305 | 1310 | // Edit the buffer before the first hunk |
| 1306 | 1311 | buffer.update(cx, |buffer, cx| { |
| @@ -1342,7 +1347,7 @@ fn test_basic_diff_hunks(cx: &mut TestAppContext) { · 35 unmodified lines | ||
| 1342 | 1347 | assert_chunks_in_ranges(&snapshot); |
| 1343 | 1348 | assert_consistent_line_numbers(&snapshot); |
| 1344 | 1349 | assert_position_translation(&snapshot); |
| 1345 | − assert_line_indents(&snapshot); | |
| 1350 | + assert_line_indents(&snapshot, cx.background_executor()); | |
| 1346 | 1351 | |
| 1347 | 1352 | // Recalculate the diff, changing the first diff hunk. |
| 1348 | 1353 | diff.update(cx, |diff, cx| { |
| @@ -2067,7 +2072,7 @@ fn test_diff_hunks_with_multiple_excerpts(cx: &mut TestAppContext) { · 718 unmodified lines | ||
| 2067 | 2072 | } |
| 2068 | 2073 | |
| 2069 | 2074 | assert_position_translation(&snapshot); |
| 2070 | − assert_line_indents(&snapshot); | |
| 2075 | + assert_line_indents(&snapshot, cx.background_executor()); | |
| 2071 | 2076 | |
| 2072 | 2077 | assert_eq!( |
| 2073 | 2078 | snapshot |
| @@ -2118,7 +2123,7 @@ fn test_diff_hunks_with_multiple_excerpts(cx: &mut TestAppContext) { · 44 unmodified lines | ||
| 2118 | 2123 | ), |
| 2119 | 2124 | ); |
| 2120 | 2125 | |
| 2121 | − assert_line_indents(&snapshot); | |
| 2126 | + assert_line_indents(&snapshot, cx.background_executor()); | |
| 2122 | 2127 | } |
| 2123 | 2128 | |
| 2124 | 2129 | /// 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 | ||
| 2888 | 2893 | ); |
| 2889 | 2894 | } |
| 2890 | 2895 | |
| 2891 | − let text_rope = Rope::from(expected_text.as_str()); | |
| 2896 | + let text_rope = Rope::from_str(expected_text.as_str(), cx.background_executor()); | |
| 2892 | 2897 | for _ in 0..10 { |
| 2893 | 2898 | let end_ix = text_rope.clip_offset(rng.random_range(0..=text_rope.len()), Bias::Right); |
| 2894 | 2899 | 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 | ||
| 3512 | 3517 | |
| 3513 | 3518 | #[track_caller] |
| 3514 | 3519 | fn assert_position_translation(snapshot: &MultiBufferSnapshot) { |
| 3515 | − let text = Rope::from(snapshot.text()); | |
| 3520 | + let text = Rope::from_str_small(&snapshot.text()); | |
| 3516 | 3521 | |
| 3517 | 3522 | let mut left_anchors = Vec::new(); |
| 3518 | 3523 | let mut right_anchors = Vec::new(); |
| @@ -3636,10 +3641,10 @@ fn assert_position_translation(snapshot: &MultiBufferSnapshot) { · 117 unmodified lines | ||
| 3636 | 3641 | } |
| 3637 | 3642 | } |
| 3638 | 3643 | |
| 3639 | −fn assert_line_indents(snapshot: &MultiBufferSnapshot) { | |
| 3644 | +fn assert_line_indents(snapshot: &MultiBufferSnapshot, executor: &BackgroundExecutor) { | |
| 3640 | 3645 | let max_row = snapshot.max_point().row; |
| 3641 | 3646 | 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); | |
| 3643 | 3648 | let mut line_indents = text |
| 3644 | 3649 | .line_indents_in_row_range(0..max_row + 1) |
| 3645 | 3650 | .collect::<Vec<_>>(); |