Pass a reference to TestAppContext in tests
This allows us to drop the context *after* we ran all futures to completion and that's crucial otherwise we'll never drop entities and/or flush effects.
This commit is contained in:
@@ -464,7 +464,7 @@ mod tests {
|
||||
use Bias::*;
|
||||
|
||||
#[gpui::test(iterations = 100)]
|
||||
async fn test_random_display_map(mut cx: gpui::TestAppContext, mut rng: StdRng) {
|
||||
async fn test_random_display_map(cx: &mut gpui::TestAppContext, mut rng: StdRng) {
|
||||
cx.foreground().set_block_on_ticks(0..=50);
|
||||
cx.foreground().forbid_parking();
|
||||
let operations = env::var("OPERATIONS")
|
||||
@@ -512,11 +512,11 @@ mod tests {
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let mut notifications = observe(&map, &mut cx);
|
||||
let mut notifications = observe(&map, cx);
|
||||
let mut fold_count = 0;
|
||||
let mut blocks = Vec::new();
|
||||
|
||||
let snapshot = map.update(&mut cx, |map, cx| map.snapshot(cx));
|
||||
let snapshot = map.update(cx, |map, cx| map.snapshot(cx));
|
||||
log::info!("buffer text: {:?}", snapshot.buffer_snapshot.text());
|
||||
log::info!("fold text: {:?}", snapshot.folds_snapshot.text());
|
||||
log::info!("tab text: {:?}", snapshot.tabs_snapshot.text());
|
||||
@@ -533,10 +533,10 @@ mod tests {
|
||||
Some(rng.gen_range(0.0..=max_wrap_width))
|
||||
};
|
||||
log::info!("setting wrap width to {:?}", wrap_width);
|
||||
map.update(&mut cx, |map, cx| map.set_wrap_width(wrap_width, cx));
|
||||
map.update(cx, |map, cx| map.set_wrap_width(wrap_width, cx));
|
||||
}
|
||||
20..=44 => {
|
||||
map.update(&mut cx, |map, cx| {
|
||||
map.update(cx, |map, cx| {
|
||||
if rng.gen() || blocks.is_empty() {
|
||||
let buffer = map.snapshot(cx).buffer_snapshot;
|
||||
let block_properties = (0..rng.gen_range(1..=1))
|
||||
@@ -582,7 +582,7 @@ mod tests {
|
||||
45..=79 => {
|
||||
let mut ranges = Vec::new();
|
||||
for _ in 0..rng.gen_range(1..=3) {
|
||||
buffer.read_with(&cx, |buffer, cx| {
|
||||
buffer.read_with(cx, |buffer, cx| {
|
||||
let buffer = buffer.read(cx);
|
||||
let end = buffer.clip_offset(rng.gen_range(0..=buffer.len()), Right);
|
||||
let start = buffer.clip_offset(rng.gen_range(0..=end), Left);
|
||||
@@ -592,26 +592,26 @@ mod tests {
|
||||
|
||||
if rng.gen() && fold_count > 0 {
|
||||
log::info!("unfolding ranges: {:?}", ranges);
|
||||
map.update(&mut cx, |map, cx| {
|
||||
map.update(cx, |map, cx| {
|
||||
map.unfold(ranges, cx);
|
||||
});
|
||||
} else {
|
||||
log::info!("folding ranges: {:?}", ranges);
|
||||
map.update(&mut cx, |map, cx| {
|
||||
map.update(cx, |map, cx| {
|
||||
map.fold(ranges, cx);
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
buffer.update(&mut cx, |buffer, cx| buffer.randomly_edit(&mut rng, 5, cx));
|
||||
buffer.update(cx, |buffer, cx| buffer.randomly_edit(&mut rng, 5, cx));
|
||||
}
|
||||
}
|
||||
|
||||
if map.read_with(&cx, |map, cx| map.is_rewrapping(cx)) {
|
||||
if map.read_with(cx, |map, cx| map.is_rewrapping(cx)) {
|
||||
notifications.next().await.unwrap();
|
||||
}
|
||||
|
||||
let snapshot = map.update(&mut cx, |map, cx| map.snapshot(cx));
|
||||
let snapshot = map.update(cx, |map, cx| map.snapshot(cx));
|
||||
fold_count = snapshot.fold_count();
|
||||
log::info!("buffer text: {:?}", snapshot.buffer_snapshot.text());
|
||||
log::info!("fold text: {:?}", snapshot.folds_snapshot.text());
|
||||
@@ -846,7 +846,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_chunks(mut cx: gpui::TestAppContext) {
|
||||
async fn test_chunks(cx: &mut gpui::TestAppContext) {
|
||||
use unindent::Unindent as _;
|
||||
|
||||
let text = r#"
|
||||
@@ -914,7 +914,7 @@ mod tests {
|
||||
]
|
||||
);
|
||||
|
||||
map.update(&mut cx, |map, cx| {
|
||||
map.update(cx, |map, cx| {
|
||||
map.fold(vec![Point::new(0, 6)..Point::new(3, 2)], cx)
|
||||
});
|
||||
assert_eq!(
|
||||
@@ -931,7 +931,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_chunks_with_soft_wrapping(mut cx: gpui::TestAppContext) {
|
||||
async fn test_chunks_with_soft_wrapping(cx: &mut gpui::TestAppContext) {
|
||||
use unindent::Unindent as _;
|
||||
|
||||
cx.foreground().set_block_on_ticks(usize::MAX..=usize::MAX);
|
||||
@@ -996,7 +996,7 @@ mod tests {
|
||||
[("{}\n\n".to_string(), None)]
|
||||
);
|
||||
|
||||
map.update(&mut cx, |map, cx| {
|
||||
map.update(cx, |map, cx| {
|
||||
map.fold(vec![Point::new(0, 6)..Point::new(3, 2)], cx)
|
||||
});
|
||||
assert_eq!(
|
||||
|
||||
@@ -1010,7 +1010,7 @@ mod tests {
|
||||
use text::Rope;
|
||||
|
||||
#[gpui::test(iterations = 100)]
|
||||
async fn test_random_wraps(mut cx: gpui::TestAppContext, mut rng: StdRng) {
|
||||
async fn test_random_wraps(cx: &mut gpui::TestAppContext, mut rng: StdRng) {
|
||||
cx.foreground().set_block_on_ticks(0..=50);
|
||||
cx.foreground().forbid_parking();
|
||||
let operations = env::var("OPERATIONS")
|
||||
@@ -1043,7 +1043,7 @@ mod tests {
|
||||
MultiBuffer::build_simple(&text, cx)
|
||||
}
|
||||
});
|
||||
let mut buffer_snapshot = buffer.read_with(&cx, |buffer, cx| buffer.snapshot(cx));
|
||||
let mut buffer_snapshot = buffer.read_with(cx, |buffer, cx| buffer.snapshot(cx));
|
||||
let (mut fold_map, folds_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
||||
let (tab_map, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), tab_size);
|
||||
log::info!("Unwrapped text (no folds): {:?}", buffer_snapshot.text());
|
||||
@@ -1059,13 +1059,13 @@ mod tests {
|
||||
|
||||
let (wrap_map, _) =
|
||||
cx.update(|cx| WrapMap::new(tabs_snapshot.clone(), font_id, font_size, wrap_width, cx));
|
||||
let mut notifications = observe(&wrap_map, &mut cx);
|
||||
let mut notifications = observe(&wrap_map, cx);
|
||||
|
||||
if wrap_map.read_with(&cx, |map, _| map.is_rewrapping()) {
|
||||
if wrap_map.read_with(cx, |map, _| map.is_rewrapping()) {
|
||||
notifications.next().await.unwrap();
|
||||
}
|
||||
|
||||
let (initial_snapshot, _) = wrap_map.update(&mut cx, |map, cx| {
|
||||
let (initial_snapshot, _) = wrap_map.update(cx, |map, cx| {
|
||||
assert!(!map.is_rewrapping());
|
||||
map.sync(tabs_snapshot.clone(), Vec::new(), cx)
|
||||
});
|
||||
@@ -1091,20 +1091,20 @@ mod tests {
|
||||
Some(rng.gen_range(0.0..=1000.0))
|
||||
};
|
||||
log::info!("Setting wrap width to {:?}", wrap_width);
|
||||
wrap_map.update(&mut cx, |map, cx| map.set_wrap_width(wrap_width, cx));
|
||||
wrap_map.update(cx, |map, cx| map.set_wrap_width(wrap_width, cx));
|
||||
}
|
||||
20..=39 => {
|
||||
for (folds_snapshot, fold_edits) in fold_map.randomly_mutate(&mut rng) {
|
||||
let (tabs_snapshot, tab_edits) = tab_map.sync(folds_snapshot, fold_edits);
|
||||
let (mut snapshot, wrap_edits) = wrap_map
|
||||
.update(&mut cx, |map, cx| map.sync(tabs_snapshot, tab_edits, cx));
|
||||
let (mut snapshot, wrap_edits) =
|
||||
wrap_map.update(cx, |map, cx| map.sync(tabs_snapshot, tab_edits, cx));
|
||||
snapshot.check_invariants();
|
||||
snapshot.verify_chunks(&mut rng);
|
||||
edits.push((snapshot, wrap_edits));
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
buffer.update(&mut cx, |buffer, cx| {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
let subscription = buffer.subscribe();
|
||||
let edit_count = rng.gen_range(1..=5);
|
||||
buffer.randomly_mutate(&mut rng, edit_count, cx);
|
||||
@@ -1125,24 +1125,23 @@ mod tests {
|
||||
|
||||
let unwrapped_text = tabs_snapshot.text();
|
||||
let expected_text = wrap_text(&unwrapped_text, wrap_width, &mut line_wrapper);
|
||||
let (mut snapshot, wrap_edits) = wrap_map.update(&mut cx, |map, cx| {
|
||||
map.sync(tabs_snapshot.clone(), tab_edits, cx)
|
||||
});
|
||||
let (mut snapshot, wrap_edits) =
|
||||
wrap_map.update(cx, |map, cx| map.sync(tabs_snapshot.clone(), tab_edits, cx));
|
||||
snapshot.check_invariants();
|
||||
snapshot.verify_chunks(&mut rng);
|
||||
edits.push((snapshot, wrap_edits));
|
||||
|
||||
if wrap_map.read_with(&cx, |map, _| map.is_rewrapping()) && rng.gen_bool(0.4) {
|
||||
if wrap_map.read_with(cx, |map, _| map.is_rewrapping()) && rng.gen_bool(0.4) {
|
||||
log::info!("Waiting for wrapping to finish");
|
||||
while wrap_map.read_with(&cx, |map, _| map.is_rewrapping()) {
|
||||
while wrap_map.read_with(cx, |map, _| map.is_rewrapping()) {
|
||||
notifications.next().await.unwrap();
|
||||
}
|
||||
wrap_map.read_with(&cx, |map, _| assert!(map.pending_edits.is_empty()));
|
||||
wrap_map.read_with(cx, |map, _| assert!(map.pending_edits.is_empty()));
|
||||
}
|
||||
|
||||
if !wrap_map.read_with(&cx, |map, _| map.is_rewrapping()) {
|
||||
if !wrap_map.read_with(cx, |map, _| map.is_rewrapping()) {
|
||||
let (mut wrapped_snapshot, wrap_edits) =
|
||||
wrap_map.update(&mut cx, |map, cx| map.sync(tabs_snapshot, Vec::new(), cx));
|
||||
wrap_map.update(cx, |map, cx| map.sync(tabs_snapshot, Vec::new(), cx));
|
||||
let actual_text = wrapped_snapshot.text();
|
||||
let actual_longest_row = wrapped_snapshot.longest_row();
|
||||
log::info!("Wrapping finished: {:?}", actual_text);
|
||||
@@ -1220,13 +1219,13 @@ mod tests {
|
||||
assert_eq!(initial_text.to_string(), snapshot_text.to_string());
|
||||
}
|
||||
|
||||
if wrap_map.read_with(&cx, |map, _| map.is_rewrapping()) {
|
||||
if wrap_map.read_with(cx, |map, _| map.is_rewrapping()) {
|
||||
log::info!("Waiting for wrapping to finish");
|
||||
while wrap_map.read_with(&cx, |map, _| map.is_rewrapping()) {
|
||||
while wrap_map.read_with(cx, |map, _| map.is_rewrapping()) {
|
||||
notifications.next().await.unwrap();
|
||||
}
|
||||
}
|
||||
wrap_map.read_with(&cx, |map, _| assert!(map.pending_edits.is_empty()));
|
||||
wrap_map.read_with(cx, |map, _| assert!(map.pending_edits.is_empty()));
|
||||
}
|
||||
|
||||
fn wrap_text(
|
||||
|
||||
+41
-41
@@ -7772,7 +7772,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_select_larger_smaller_syntax_node(mut cx: gpui::TestAppContext) {
|
||||
async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
let language = Arc::new(Language::new(
|
||||
LanguageConfig::default(),
|
||||
@@ -7794,7 +7794,7 @@ mod tests {
|
||||
view.condition(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
view.update(&mut cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(
|
||||
&[
|
||||
DisplayPoint::new(0, 25)..DisplayPoint::new(0, 25),
|
||||
@@ -7806,7 +7806,7 @@ mod tests {
|
||||
view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx);
|
||||
});
|
||||
assert_eq!(
|
||||
view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
view.update(cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
&[
|
||||
DisplayPoint::new(0, 23)..DisplayPoint::new(0, 27),
|
||||
DisplayPoint::new(2, 35)..DisplayPoint::new(2, 7),
|
||||
@@ -7814,50 +7814,50 @@ mod tests {
|
||||
]
|
||||
);
|
||||
|
||||
view.update(&mut cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx);
|
||||
});
|
||||
assert_eq!(
|
||||
view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
view.update(cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
&[
|
||||
DisplayPoint::new(0, 16)..DisplayPoint::new(0, 28),
|
||||
DisplayPoint::new(4, 1)..DisplayPoint::new(2, 0),
|
||||
]
|
||||
);
|
||||
|
||||
view.update(&mut cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx);
|
||||
});
|
||||
assert_eq!(
|
||||
view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
view.update(cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
&[DisplayPoint::new(5, 0)..DisplayPoint::new(0, 0)]
|
||||
);
|
||||
|
||||
// Trying to expand the selected syntax node one more time has no effect.
|
||||
view.update(&mut cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx);
|
||||
});
|
||||
assert_eq!(
|
||||
view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
view.update(cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
&[DisplayPoint::new(5, 0)..DisplayPoint::new(0, 0)]
|
||||
);
|
||||
|
||||
view.update(&mut cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_smaller_syntax_node(&SelectSmallerSyntaxNode, cx);
|
||||
});
|
||||
assert_eq!(
|
||||
view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
view.update(cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
&[
|
||||
DisplayPoint::new(0, 16)..DisplayPoint::new(0, 28),
|
||||
DisplayPoint::new(4, 1)..DisplayPoint::new(2, 0),
|
||||
]
|
||||
);
|
||||
|
||||
view.update(&mut cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_smaller_syntax_node(&SelectSmallerSyntaxNode, cx);
|
||||
});
|
||||
assert_eq!(
|
||||
view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
view.update(cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
&[
|
||||
DisplayPoint::new(0, 23)..DisplayPoint::new(0, 27),
|
||||
DisplayPoint::new(2, 35)..DisplayPoint::new(2, 7),
|
||||
@@ -7865,11 +7865,11 @@ mod tests {
|
||||
]
|
||||
);
|
||||
|
||||
view.update(&mut cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_smaller_syntax_node(&SelectSmallerSyntaxNode, cx);
|
||||
});
|
||||
assert_eq!(
|
||||
view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
view.update(cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
&[
|
||||
DisplayPoint::new(0, 25)..DisplayPoint::new(0, 25),
|
||||
DisplayPoint::new(2, 24)..DisplayPoint::new(2, 12),
|
||||
@@ -7878,11 +7878,11 @@ mod tests {
|
||||
);
|
||||
|
||||
// Trying to shrink the selected syntax node one more time has no effect.
|
||||
view.update(&mut cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_smaller_syntax_node(&SelectSmallerSyntaxNode, cx);
|
||||
});
|
||||
assert_eq!(
|
||||
view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
view.update(cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
&[
|
||||
DisplayPoint::new(0, 25)..DisplayPoint::new(0, 25),
|
||||
DisplayPoint::new(2, 24)..DisplayPoint::new(2, 12),
|
||||
@@ -7892,7 +7892,7 @@ mod tests {
|
||||
|
||||
// Ensure that we keep expanding the selection if the larger selection starts or ends within
|
||||
// a fold.
|
||||
view.update(&mut cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.fold_ranges(
|
||||
vec![
|
||||
Point::new(0, 21)..Point::new(0, 24),
|
||||
@@ -7903,7 +7903,7 @@ mod tests {
|
||||
view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx);
|
||||
});
|
||||
assert_eq!(
|
||||
view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
view.update(cx, |view, cx| view.selected_display_ranges(cx)),
|
||||
&[
|
||||
DisplayPoint::new(0, 16)..DisplayPoint::new(0, 28),
|
||||
DisplayPoint::new(2, 35)..DisplayPoint::new(2, 7),
|
||||
@@ -7913,7 +7913,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_autoindent_selections(mut cx: gpui::TestAppContext) {
|
||||
async fn test_autoindent_selections(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
let language = Arc::new(
|
||||
Language::new(
|
||||
@@ -7954,7 +7954,7 @@ mod tests {
|
||||
.condition(&cx, |editor, cx| !editor.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
editor.update(&mut cx, |editor, cx| {
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor.select_ranges([5..5, 8..8, 9..9], None, cx);
|
||||
editor.newline(&Newline, cx);
|
||||
assert_eq!(editor.text(cx), "fn a(\n \n) {\n \n}\n");
|
||||
@@ -7970,7 +7970,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_autoclose_pairs(mut cx: gpui::TestAppContext) {
|
||||
async fn test_autoclose_pairs(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
let language = Arc::new(Language::new(
|
||||
LanguageConfig {
|
||||
@@ -8007,7 +8007,7 @@ mod tests {
|
||||
view.condition(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
view.update(&mut cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(
|
||||
&[
|
||||
DisplayPoint::new(0, 0)..DisplayPoint::new(0, 1),
|
||||
@@ -8081,7 +8081,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_snippets(mut cx: gpui::TestAppContext) {
|
||||
async fn test_snippets(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
|
||||
let text = "
|
||||
@@ -8093,7 +8093,7 @@ mod tests {
|
||||
let buffer = cx.update(|cx| MultiBuffer::build_simple(&text, cx));
|
||||
let (_, editor) = cx.add_window(|cx| build_editor(buffer, settings, cx));
|
||||
|
||||
editor.update(&mut cx, |editor, cx| {
|
||||
editor.update(cx, |editor, cx| {
|
||||
let buffer = &editor.snapshot(cx).buffer_snapshot;
|
||||
let snippet = Snippet::parse("f(${1:one}, ${2:two}, ${1:three})$0").unwrap();
|
||||
let insertion_ranges = [
|
||||
@@ -8188,7 +8188,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_completion(mut cx: gpui::TestAppContext) {
|
||||
async fn test_completion(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
let (language_server, mut fake) = cx.update(|cx| {
|
||||
lsp::LanguageServer::fake_with_capabilities(
|
||||
@@ -8213,23 +8213,23 @@ mod tests {
|
||||
let fs = FakeFs::new(cx.background().clone());
|
||||
fs.insert_file("/file", text).await;
|
||||
|
||||
let project = Project::test(fs, &mut cx);
|
||||
let project = Project::test(fs, cx);
|
||||
|
||||
let (worktree, relative_path) = project
|
||||
.update(&mut cx, |project, cx| {
|
||||
.update(cx, |project, cx| {
|
||||
project.find_or_create_local_worktree("/file", false, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let project_path = ProjectPath {
|
||||
worktree_id: worktree.read_with(&cx, |worktree, _| worktree.id()),
|
||||
worktree_id: worktree.read_with(cx, |worktree, _| worktree.id()),
|
||||
path: relative_path.into(),
|
||||
};
|
||||
let buffer = project
|
||||
.update(&mut cx, |project, cx| project.open_buffer(project_path, cx))
|
||||
.update(cx, |project, cx| project.open_buffer(project_path, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
buffer.update(&mut cx, |buffer, cx| {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
buffer.set_language_server(Some(language_server), cx);
|
||||
});
|
||||
|
||||
@@ -8238,7 +8238,7 @@ mod tests {
|
||||
|
||||
let (_, editor) = cx.add_window(|cx| build_editor(buffer, settings, cx));
|
||||
|
||||
editor.update(&mut cx, |editor, cx| {
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor.project = Some(project);
|
||||
editor.select_ranges([Point::new(0, 3)..Point::new(0, 3)], None, cx);
|
||||
editor.handle_input(&Input(".".to_string()), cx);
|
||||
@@ -8258,7 +8258,7 @@ mod tests {
|
||||
.condition(&cx, |editor, _| editor.context_menu_visible())
|
||||
.await;
|
||||
|
||||
let apply_additional_edits = editor.update(&mut cx, |editor, cx| {
|
||||
let apply_additional_edits = editor.update(cx, |editor, cx| {
|
||||
editor.move_down(&MoveDown, cx);
|
||||
let apply_additional_edits = editor
|
||||
.confirm_completion(&ConfirmCompletion(None), cx)
|
||||
@@ -8282,7 +8282,7 @@ mod tests {
|
||||
.await;
|
||||
apply_additional_edits.await.unwrap();
|
||||
assert_eq!(
|
||||
editor.read_with(&cx, |editor, cx| editor.text(cx)),
|
||||
editor.read_with(cx, |editor, cx| editor.text(cx)),
|
||||
"
|
||||
one.second_completion
|
||||
two
|
||||
@@ -8292,7 +8292,7 @@ mod tests {
|
||||
.unindent()
|
||||
);
|
||||
|
||||
editor.update(&mut cx, |editor, cx| {
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor.select_ranges(
|
||||
[
|
||||
Point::new(1, 3)..Point::new(1, 3),
|
||||
@@ -8323,7 +8323,7 @@ mod tests {
|
||||
.condition(&cx, |editor, _| editor.context_menu_visible())
|
||||
.await;
|
||||
|
||||
editor.update(&mut cx, |editor, cx| {
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor.handle_input(&Input("i".to_string()), cx);
|
||||
});
|
||||
|
||||
@@ -8342,7 +8342,7 @@ mod tests {
|
||||
.condition(&cx, |editor, _| editor.context_menu_visible())
|
||||
.await;
|
||||
|
||||
let apply_additional_edits = editor.update(&mut cx, |editor, cx| {
|
||||
let apply_additional_edits = editor.update(cx, |editor, cx| {
|
||||
let apply_additional_edits = editor
|
||||
.confirm_completion(&ConfirmCompletion(None), cx)
|
||||
.unwrap();
|
||||
@@ -8421,7 +8421,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_toggle_comment(mut cx: gpui::TestAppContext) {
|
||||
async fn test_toggle_comment(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
let language = Arc::new(Language::new(
|
||||
LanguageConfig {
|
||||
@@ -8444,7 +8444,7 @@ mod tests {
|
||||
let buffer = cx.add_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (_, view) = cx.add_window(|cx| build_editor(buffer, settings, cx));
|
||||
|
||||
view.update(&mut cx, |editor, cx| {
|
||||
view.update(cx, |editor, cx| {
|
||||
// If multiple selections intersect a line, the line is only
|
||||
// toggled once.
|
||||
editor.select_display_ranges(
|
||||
@@ -8678,7 +8678,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_extra_newline_insertion(mut cx: gpui::TestAppContext) {
|
||||
async fn test_extra_newline_insertion(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
let language = Arc::new(Language::new(
|
||||
LanguageConfig {
|
||||
@@ -8715,7 +8715,7 @@ mod tests {
|
||||
view.condition(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
view.update(&mut cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(
|
||||
&[
|
||||
DisplayPoint::new(0, 2)..DisplayPoint::new(0, 3),
|
||||
|
||||
Reference in New Issue
Block a user