@@ -1307,49 +1307,55 @@ pub mod tests {
cx.executor().run_until_parked();
let mut edits_made = 1;
- _ = editor.update(cx, |editor, cx| {
- let expected_hints = vec!["0".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "Should get its first hints when opening the editor"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- let inlay_cache = editor.inlay_hint_cache();
- assert_eq!(
- inlay_cache.allowed_hint_kinds, allowed_hint_kinds,
- "Cache should use editor settings to get the allowed hint kinds"
- );
- assert_eq!(
- inlay_cache.version, edits_made,
- "The editor update the cache version after every cache/view change"
- );
- });
+ editor
+ .update(cx, |editor, cx| {
+ let expected_hints = vec!["0".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "Should get its first hints when opening the editor"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ let inlay_cache = editor.inlay_hint_cache();
+ assert_eq!(
+ inlay_cache.allowed_hint_kinds, allowed_hint_kinds,
+ "Cache should use editor settings to get the allowed hint kinds"
+ );
+ assert_eq!(
+ inlay_cache.version, edits_made,
+ "The editor update the cache version after every cache/view change"
+ );
+ })
+ .unwrap();
- _ = editor.update(cx, |editor, cx| {
- editor.change_selections(None, cx, |s| s.select_ranges([13..13]));
- editor.handle_input("some change", cx);
- edits_made += 1;
- });
+ editor
+ .update(cx, |editor, cx| {
+ editor.change_selections(None, cx, |s| s.select_ranges([13..13]));
+ editor.handle_input("some change", cx);
+ edits_made += 1;
+ })
+ .unwrap();
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
- let expected_hints = vec!["0".to_string(), "1".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "Should get new hints after an edit"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- let inlay_cache = editor.inlay_hint_cache();
- assert_eq!(
- inlay_cache.allowed_hint_kinds, allowed_hint_kinds,
- "Cache should use editor settings to get the allowed hint kinds"
- );
- assert_eq!(
- inlay_cache.version, edits_made,
- "The editor update the cache version after every cache/view change"
- );
- });
+ editor
+ .update(cx, |editor, cx| {
+ let expected_hints = vec!["0".to_string(), "1".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "Should get new hints after an edit"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ let inlay_cache = editor.inlay_hint_cache();
+ assert_eq!(
+ inlay_cache.allowed_hint_kinds, allowed_hint_kinds,
+ "Cache should use editor settings to get the allowed hint kinds"
+ );
+ assert_eq!(
+ inlay_cache.version, edits_made,
+ "The editor update the cache version after every cache/view change"
+ );
+ })
+ .unwrap();
fake_server
.request::<lsp::request::InlayHintRefreshRequest>(())
@@ -1357,24 +1363,26 @@ pub mod tests {
.expect("inlay refresh request failed");
edits_made += 1;
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
- let expected_hints = vec!["0".to_string(), "1".to_string(), "2".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "Should get new hints after hint refresh/ request"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- let inlay_cache = editor.inlay_hint_cache();
- assert_eq!(
- inlay_cache.allowed_hint_kinds, allowed_hint_kinds,
- "Cache should use editor settings to get the allowed hint kinds"
- );
- assert_eq!(
- inlay_cache.version, edits_made,
- "The editor update the cache version after every cache/view change"
- );
- });
+ editor
+ .update(cx, |editor, cx| {
+ let expected_hints = vec!["0".to_string(), "1".to_string(), "2".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "Should get new hints after hint refresh/ request"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ let inlay_cache = editor.inlay_hint_cache();
+ assert_eq!(
+ inlay_cache.allowed_hint_kinds, allowed_hint_kinds,
+ "Cache should use editor settings to get the allowed hint kinds"
+ );
+ assert_eq!(
+ inlay_cache.version, edits_made,
+ "The editor update the cache version after every cache/view change"
+ );
+ })
+ .unwrap();
}
#[gpui::test]
@@ -1417,20 +1425,22 @@ pub mod tests {
cx.executor().run_until_parked();
let mut edits_made = 1;
- _ = editor.update(cx, |editor, cx| {
- let expected_hints = vec!["0".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "Should get its first hints when opening the editor"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- assert_eq!(
- editor.inlay_hint_cache().version,
- edits_made,
- "The editor update the cache version after every cache/view change"
- );
- });
+ editor
+ .update(cx, |editor, cx| {
+ let expected_hints = vec!["0".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "Should get its first hints when opening the editor"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ assert_eq!(
+ editor.inlay_hint_cache().version,
+ edits_made,
+ "The editor update the cache version after every cache/view change"
+ );
+ })
+ .unwrap();
let progress_token = "test_progress_token";
fake_server
@@ -1448,20 +1458,22 @@ pub mod tests {
});
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
- let expected_hints = vec!["0".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "Should not update hints while the work task is running"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- assert_eq!(
- editor.inlay_hint_cache().version,
- edits_made,
- "Should not update the cache while the work task is running"
- );
- });
+ editor
+ .update(cx, |editor, cx| {
+ let expected_hints = vec!["0".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "Should not update hints while the work task is running"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ assert_eq!(
+ editor.inlay_hint_cache().version,
+ edits_made,
+ "Should not update the cache while the work task is running"
+ );
+ })
+ .unwrap();
fake_server.notify::<lsp::notification::Progress>(lsp::ProgressParams {
token: lsp::ProgressToken::String(progress_token.to_string()),
@@ -1472,20 +1484,22 @@ pub mod tests {
cx.executor().run_until_parked();
edits_made += 1;
- _ = editor.update(cx, |editor, cx| {
- let expected_hints = vec!["1".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "New hints should be queried after the work task is done"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- assert_eq!(
- editor.inlay_hint_cache().version,
- edits_made,
- "Cache version should update once after the work task is done"
- );
- });
+ editor
+ .update(cx, |editor, cx| {
+ let expected_hints = vec!["1".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "New hints should be queried after the work task is done"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ assert_eq!(
+ editor.inlay_hint_cache().version,
+ edits_made,
+ "Cache version should update once after the work task is done"
+ );
+ })
+ .unwrap();
}
#[gpui::test]
@@ -1577,20 +1591,22 @@ pub mod tests {
.next()
.await;
cx.executor().run_until_parked();
- _ = rs_editor.update(cx, |editor, cx| {
- let expected_hints = vec!["0".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "Should get its first hints when opening the editor"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- assert_eq!(
- editor.inlay_hint_cache().version,
- 1,
- "Rust editor update the cache version after every cache/view change"
- );
- });
+ rs_editor
+ .update(cx, |editor, cx| {
+ let expected_hints = vec!["0".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "Should get its first hints when opening the editor"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ assert_eq!(
+ editor.inlay_hint_cache().version,
+ 1,
+ "Rust editor update the cache version after every cache/view change"
+ );
+ })
+ .unwrap();
cx.executor().run_until_parked();
let md_buffer = project
@@ -1628,72 +1644,86 @@ pub mod tests {
.next()
.await;
cx.executor().run_until_parked();
- _ = md_editor.update(cx, |editor, cx| {
- let expected_hints = vec!["0".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "Markdown editor should have a separate version, repeating Rust editor rules"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- assert_eq!(editor.inlay_hint_cache().version, 1);
- });
+ md_editor
+ .update(cx, |editor, cx| {
+ let expected_hints = vec!["0".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "Markdown editor should have a separate version, repeating Rust editor rules"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ assert_eq!(editor.inlay_hint_cache().version, 1);
+ })
+ .unwrap();
- _ = rs_editor.update(cx, |editor, cx| {
- editor.change_selections(None, cx, |s| s.select_ranges([13..13]));
- editor.handle_input("some rs change", cx);
- });
+ rs_editor
+ .update(cx, |editor, cx| {
+ editor.change_selections(None, cx, |s| s.select_ranges([13..13]));
+ editor.handle_input("some rs change", cx);
+ })
+ .unwrap();
cx.executor().run_until_parked();
- _ = rs_editor.update(cx, |editor, cx| {
- let expected_hints = vec!["1".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "Rust inlay cache should change after the edit"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- assert_eq!(
- editor.inlay_hint_cache().version,
- 2,
- "Every time hint cache changes, cache version should be incremented"
- );
- });
- _ = md_editor.update(cx, |editor, cx| {
- let expected_hints = vec!["0".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "Markdown editor should not be affected by Rust editor changes"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- assert_eq!(editor.inlay_hint_cache().version, 1);
- });
+ rs_editor
+ .update(cx, |editor, cx| {
+ let expected_hints = vec!["1".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "Rust inlay cache should change after the edit"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ assert_eq!(
+ editor.inlay_hint_cache().version,
+ 2,
+ "Every time hint cache changes, cache version should be incremented"
+ );
+ })
+ .unwrap();
+ md_editor
+ .update(cx, |editor, cx| {
+ let expected_hints = vec!["0".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "Markdown editor should not be affected by Rust editor changes"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ assert_eq!(editor.inlay_hint_cache().version, 1);
+ })
+ .unwrap();
- _ = md_editor.update(cx, |editor, cx| {
- editor.change_selections(None, cx, |s| s.select_ranges([13..13]));
- editor.handle_input("some md change", cx);
- });
+ md_editor
+ .update(cx, |editor, cx| {
+ editor.change_selections(None, cx, |s| s.select_ranges([13..13]));
+ editor.handle_input("some md change", cx);
+ })
+ .unwrap();
cx.executor().run_until_parked();
- _ = md_editor.update(cx, |editor, cx| {
- let expected_hints = vec!["1".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "Rust editor should not be affected by Markdown editor changes"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- assert_eq!(editor.inlay_hint_cache().version, 2);
- });
- _ = rs_editor.update(cx, |editor, cx| {
- let expected_hints = vec!["1".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "Markdown editor should also change independently"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- assert_eq!(editor.inlay_hint_cache().version, 2);
- });
+ md_editor
+ .update(cx, |editor, cx| {
+ let expected_hints = vec!["1".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "Rust editor should not be affected by Markdown editor changes"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ assert_eq!(editor.inlay_hint_cache().version, 2);
+ })
+ .unwrap();
+ rs_editor
+ .update(cx, |editor, cx| {
+ let expected_hints = vec!["1".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "Markdown editor should also change independently"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ assert_eq!(editor.inlay_hint_cache().version, 2);
+ })
+ .unwrap();
}
#[gpui::test]
@@ -1759,66 +1789,70 @@ pub mod tests {
cx.executor().run_until_parked();
let mut edits_made = 1;
- _ = editor.update(cx, |editor, cx| {
- assert_eq!(
- lsp_request_count.load(Ordering::Relaxed),
- 1,
- "Should query new hints once"
- );
- assert_eq!(
- vec![
- "other hint".to_string(),
- "parameter hint".to_string(),
- "type hint".to_string(),
- ],
- cached_hint_labels(editor),
- "Should get its first hints when opening the editor"
- );
- assert_eq!(
- vec!["other hint".to_string(), "type hint".to_string()],
- visible_hint_labels(editor, cx)
- );
- let inlay_cache = editor.inlay_hint_cache();
- assert_eq!(
- inlay_cache.allowed_hint_kinds, allowed_hint_kinds,
- "Cache should use editor settings to get the allowed hint kinds"
- );
- assert_eq!(
- inlay_cache.version, edits_made,
- "The editor update the cache version after every cache/view change"
- );
- });
+ editor
+ .update(cx, |editor, cx| {
+ assert_eq!(
+ lsp_request_count.load(Ordering::Relaxed),
+ 1,
+ "Should query new hints once"
+ );
+ assert_eq!(
+ vec![
+ "other hint".to_string(),
+ "parameter hint".to_string(),
+ "type hint".to_string(),
+ ],
+ cached_hint_labels(editor),
+ "Should get its first hints when opening the editor"
+ );
+ assert_eq!(
+ vec!["other hint".to_string(), "type hint".to_string()],
+ visible_hint_labels(editor, cx)
+ );
+ let inlay_cache = editor.inlay_hint_cache();
+ assert_eq!(
+ inlay_cache.allowed_hint_kinds, allowed_hint_kinds,
+ "Cache should use editor settings to get the allowed hint kinds"
+ );
+ assert_eq!(
+ inlay_cache.version, edits_made,
+ "The editor update the cache version after every cache/view change"
+ );
+ })
+ .unwrap();
fake_server
.request::<lsp::request::InlayHintRefreshRequest>(())
.await
.expect("inlay refresh request failed");
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
- assert_eq!(
- lsp_request_count.load(Ordering::Relaxed),
- 2,
- "Should load new hints twice"
- );
- assert_eq!(
- vec![
- "other hint".to_string(),
- "parameter hint".to_string(),
- "type hint".to_string(),
- ],
- cached_hint_labels(editor),
- "Cached hints should not change due to allowed hint kinds settings update"
- );
- assert_eq!(
- vec!["other hint".to_string(), "type hint".to_string()],
- visible_hint_labels(editor, cx)
- );
- assert_eq!(
- editor.inlay_hint_cache().version,
- edits_made,
- "Should not update cache version due to new loaded hints being the same"
- );
- });
+ editor
+ .update(cx, |editor, cx| {
+ assert_eq!(
+ lsp_request_count.load(Ordering::Relaxed),
+ 2,
+ "Should load new hints twice"
+ );
+ assert_eq!(
+ vec![
+ "other hint".to_string(),
+ "parameter hint".to_string(),
+ "type hint".to_string(),
+ ],
+ cached_hint_labels(editor),
+ "Cached hints should not change due to allowed hint kinds settings update"
+ );
+ assert_eq!(
+ vec!["other hint".to_string(), "type hint".to_string()],
+ visible_hint_labels(editor, cx)
+ );
+ assert_eq!(
+ editor.inlay_hint_cache().version,
+ edits_made,
+ "Should not update cache version due to new loaded hints being the same"
+ );
+ })
+ .unwrap();
for (new_allowed_hint_kinds, expected_visible_hints) in [
(HashSet::from_iter([None]), vec!["other hint".to_string()]),
@@ -1866,7 +1900,7 @@ pub mod tests {
})
});
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
+ editor.update(cx, |editor, cx| {
assert_eq!(
lsp_request_count.load(Ordering::Relaxed),
2,
@@ -1895,7 +1929,7 @@ pub mod tests {
inlay_cache.version, edits_made,
"The editor should update the cache version after every cache/view change for hint kinds {new_allowed_hint_kinds:?} due to visible hints change"
);
- });
+ }).unwrap();
}
edits_made += 1;
@@ -1910,37 +1944,39 @@ pub mod tests {
})
});
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
- assert_eq!(
- lsp_request_count.load(Ordering::Relaxed),
- 2,
- "Should not load new hints when hints got disabled"
- );
- assert!(
- cached_hint_labels(editor).is_empty(),
- "Should clear the cache when hints got disabled"
- );
- assert!(
- visible_hint_labels(editor, cx).is_empty(),
- "Should clear visible hints when hints got disabled"
- );
- let inlay_cache = editor.inlay_hint_cache();
- assert_eq!(
- inlay_cache.allowed_hint_kinds, another_allowed_hint_kinds,
- "Should update its allowed hint kinds even when hints got disabled"
- );
- assert_eq!(
- inlay_cache.version, edits_made,
- "The editor should update the cache version after hints got disabled"
- );
- });
+ editor
+ .update(cx, |editor, cx| {
+ assert_eq!(
+ lsp_request_count.load(Ordering::Relaxed),
+ 2,
+ "Should not load new hints when hints got disabled"
+ );
+ assert!(
+ cached_hint_labels(editor).is_empty(),
+ "Should clear the cache when hints got disabled"
+ );
+ assert!(
+ visible_hint_labels(editor, cx).is_empty(),
+ "Should clear visible hints when hints got disabled"
+ );
+ let inlay_cache = editor.inlay_hint_cache();
+ assert_eq!(
+ inlay_cache.allowed_hint_kinds, another_allowed_hint_kinds,
+ "Should update its allowed hint kinds even when hints got disabled"
+ );
+ assert_eq!(
+ inlay_cache.version, edits_made,
+ "The editor should update the cache version after hints got disabled"
+ );
+ })
+ .unwrap();
fake_server
.request::<lsp::request::InlayHintRefreshRequest>(())
.await
.expect("inlay refresh request failed");
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
+ editor.update(cx, |editor, cx| {
assert_eq!(
lsp_request_count.load(Ordering::Relaxed),
2,
@@ -1952,7 +1988,7 @@ pub mod tests {
editor.inlay_hint_cache().version, edits_made,
"The editor should not update the cache version after /refresh query without updates"
);
- });
+ }).unwrap();
let final_allowed_hint_kinds = HashSet::from_iter([Some(InlayHintKind::Parameter)]);
edits_made += 1;
@@ -1966,62 +2002,66 @@ pub mod tests {
})
});
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
- assert_eq!(
- lsp_request_count.load(Ordering::Relaxed),
- 3,
- "Should query for new hints when they got re-enabled"
- );
- assert_eq!(
- vec![
- "other hint".to_string(),
- "parameter hint".to_string(),
- "type hint".to_string(),
- ],
- cached_hint_labels(editor),
- "Should get its cached hints fully repopulated after the hints got re-enabled"
- );
- assert_eq!(
- vec!["parameter hint".to_string()],
- visible_hint_labels(editor, cx),
- "Should get its visible hints repopulated and filtered after the h"
- );
- let inlay_cache = editor.inlay_hint_cache();
- assert_eq!(
- inlay_cache.allowed_hint_kinds, final_allowed_hint_kinds,
- "Cache should update editor settings when hints got re-enabled"
- );
- assert_eq!(
- inlay_cache.version, edits_made,
- "Cache should update its version after hints got re-enabled"
- );
- });
+ editor
+ .update(cx, |editor, cx| {
+ assert_eq!(
+ lsp_request_count.load(Ordering::Relaxed),
+ 3,
+ "Should query for new hints when they got re-enabled"
+ );
+ assert_eq!(
+ vec![
+ "other hint".to_string(),
+ "parameter hint".to_string(),
+ "type hint".to_string(),
+ ],
+ cached_hint_labels(editor),
+ "Should get its cached hints fully repopulated after the hints got re-enabled"
+ );
+ assert_eq!(
+ vec!["parameter hint".to_string()],
+ visible_hint_labels(editor, cx),
+ "Should get its visible hints repopulated and filtered after the h"
+ );
+ let inlay_cache = editor.inlay_hint_cache();
+ assert_eq!(
+ inlay_cache.allowed_hint_kinds, final_allowed_hint_kinds,
+ "Cache should update editor settings when hints got re-enabled"
+ );
+ assert_eq!(
+ inlay_cache.version, edits_made,
+ "Cache should update its version after hints got re-enabled"
+ );
+ })
+ .unwrap();
fake_server
.request::<lsp::request::InlayHintRefreshRequest>(())
.await
.expect("inlay refresh request failed");
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
- assert_eq!(
- lsp_request_count.load(Ordering::Relaxed),
- 4,
- "Should query for new hints again"
- );
- assert_eq!(
- vec![
- "other hint".to_string(),
- "parameter hint".to_string(),
- "type hint".to_string(),
- ],
- cached_hint_labels(editor),
- );
- assert_eq!(
- vec!["parameter hint".to_string()],
- visible_hint_labels(editor, cx),
- );
- assert_eq!(editor.inlay_hint_cache().version, edits_made);
- });
+ editor
+ .update(cx, |editor, cx| {
+ assert_eq!(
+ lsp_request_count.load(Ordering::Relaxed),
+ 4,
+ "Should query for new hints again"
+ );
+ assert_eq!(
+ vec![
+ "other hint".to_string(),
+ "parameter hint".to_string(),
+ "type hint".to_string(),
+ ],
+ cached_hint_labels(editor),
+ );
+ assert_eq!(
+ vec!["parameter hint".to_string()],
+ visible_hint_labels(editor, cx),
+ );
+ assert_eq!(editor.inlay_hint_cache().version, edits_made);
+ })
+ .unwrap();
}
#[gpui::test]
@@ -2069,16 +2109,18 @@ pub mod tests {
"initial change #2",
"initial change #3",
] {
- _ = editor.update(cx, |editor, cx| {
- editor.change_selections(None, cx, |s| s.select_ranges([13..13]));
- editor.handle_input(change_after_opening, cx);
- });
+ editor
+ .update(cx, |editor, cx| {
+ editor.change_selections(None, cx, |s| s.select_ranges([13..13]));
+ editor.handle_input(change_after_opening, cx);
+ })
+ .unwrap();
expected_changes.push(change_after_opening);
}
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
+ editor.update(cx, |editor, cx| {
let current_text = editor.text(cx);
for change in &expected_changes {
assert!(
@@ -2102,7 +2144,7 @@ pub mod tests {
editor.inlay_hint_cache().version, 1,
"Only one update should be registered in the cache after all cancellations"
);
- });
+ }).unwrap();
let mut edits = Vec::new();
for async_later_change in [
@@ -2113,41 +2155,45 @@ pub mod tests {
expected_changes.push(async_later_change);
let task_editor = editor.clone();
edits.push(cx.spawn(|mut cx| async move {
- _ = task_editor.update(&mut cx, |editor, cx| {
- editor.change_selections(None, cx, |s| s.select_ranges([13..13]));
- editor.handle_input(async_later_change, cx);
- });
+ task_editor
+ .update(&mut cx, |editor, cx| {
+ editor.change_selections(None, cx, |s| s.select_ranges([13..13]));
+ editor.handle_input(async_later_change, cx);
+ })
+ .unwrap();
}));
}
let _ = future::join_all(edits).await;
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
- let current_text = editor.text(cx);
- for change in &expected_changes {
- assert!(
- current_text.contains(change),
- "Should apply all changes made"
+ editor
+ .update(cx, |editor, cx| {
+ let current_text = editor.text(cx);
+ for change in &expected_changes {
+ assert!(
+ current_text.contains(change),
+ "Should apply all changes made"
+ );
+ }
+ assert_eq!(
+ lsp_request_count.load(Ordering::SeqCst),
+ 3,
+ "Should query new hints one more time, for the last edit only"
);
- }
- assert_eq!(
- lsp_request_count.load(Ordering::SeqCst),
- 3,
- "Should query new hints one more time, for the last edit only"
- );
- let expected_hints = vec!["3".to_string()];
- assert_eq!(
- expected_hints,
- cached_hint_labels(editor),
- "Should get hints from the last edit landed only"
- );
- assert_eq!(expected_hints, visible_hint_labels(editor, cx));
- assert_eq!(
- editor.inlay_hint_cache().version,
- 2,
- "Should update the cache version once more, for the new change"
- );
- });
+ let expected_hints = vec!["3".to_string()];
+ assert_eq!(
+ expected_hints,
+ cached_hint_labels(editor),
+ "Should get hints from the last edit landed only"
+ );
+ assert_eq!(expected_hints, visible_hint_labels(editor, cx));
+ assert_eq!(
+ editor.inlay_hint_cache().version,
+ 2,
+ "Should update the cache version once more, for the new change"
+ );
+ })
+ .unwrap();
}
#[gpui::test(iterations = 10)]
@@ -2280,7 +2326,7 @@ pub mod tests {
lsp::Position::new(initial_visible_range.end.row * 2, 2);
let mut expected_invisible_query_start = lsp_initial_visible_range.end;
expected_invisible_query_start.character += 1;
- _ = editor.update(cx, |editor, cx| {
+ editor.update(cx, |editor, cx| {
let ranges = lsp_request_ranges.lock().drain(..).collect::<Vec<_>>();
assert_eq!(ranges.len(), 2,
"When scroll is at the edge of a big document, its visible part and the same range further should be queried in order, but got: {ranges:?}");
@@ -2305,12 +2351,14 @@ pub mod tests {
editor.inlay_hint_cache().version, requests_count,
"LSP queries should've bumped the cache version"
);
- });
+ }).unwrap();
- _ = editor.update(cx, |editor, cx| {
- editor.scroll_screen(&ScrollAmount::Page(1.0), cx);
- editor.scroll_screen(&ScrollAmount::Page(1.0), cx);
- });
+ editor
+ .update(cx, |editor, cx| {
+ editor.scroll_screen(&ScrollAmount::Page(1.0), cx);
+ editor.scroll_screen(&ScrollAmount::Page(1.0), cx);
+ })
+ .unwrap();
cx.executor().advance_clock(Duration::from_millis(
INVISIBLE_RANGES_HINTS_REQUEST_DELAY_MILLIS + 100,
));
@@ -2377,16 +2425,18 @@ pub mod tests {
})
.unwrap();
- _ = editor.update(cx, |editor, cx| {
- editor.change_selections(Some(Autoscroll::center()), cx, |s| {
- s.select_ranges([selection_in_cached_range..selection_in_cached_range])
- });
- });
+ editor
+ .update(cx, |editor, cx| {
+ editor.change_selections(Some(Autoscroll::center()), cx, |s| {
+ s.select_ranges([selection_in_cached_range..selection_in_cached_range])
+ });
+ })
+ .unwrap();
cx.executor().advance_clock(Duration::from_millis(
INVISIBLE_RANGES_HINTS_REQUEST_DELAY_MILLIS + 100,
));
cx.executor().run_until_parked();
- _ = editor.update(cx, |_, _| {
+ editor.update(cx, |_, _| {
let ranges = lsp_request_ranges
.lock()
.drain(..)
@@ -2394,16 +2444,18 @@ pub mod tests {
.collect::<Vec<_>>();
assert!(ranges.is_empty(), "No new ranges or LSP queries should be made after returning to the selection with cached hints");
assert_eq!(lsp_request_count.load(Ordering::Acquire), 4);
- });
+ }).unwrap();
- _ = editor.update(cx, |editor, cx| {
- editor.handle_input("++++more text++++", cx);
- });
+ editor
+ .update(cx, |editor, cx| {
+ editor.handle_input("++++more text++++", cx);
+ })
+ .unwrap();
cx.executor().advance_clock(Duration::from_millis(
INVISIBLE_RANGES_HINTS_REQUEST_DELAY_MILLIS + 100,
));
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
+ editor.update(cx, |editor, cx| {
let mut ranges = lsp_request_ranges.lock().drain(..).collect::<Vec<_>>();
ranges.sort_by_key(|r| r.start);
@@ -2432,7 +2484,7 @@ pub mod tests {
"Should have hints from the new LSP response after the edit");
assert_eq!(expected_hints, visible_hint_labels(editor, cx));
assert_eq!(editor.inlay_hint_cache().version, lsp_requests, "Should update the cache for every LSP response with hints added");
- });
+ }).unwrap();
}
#[gpui::test(iterations = 30)]
@@ -2631,7 +2683,7 @@ pub mod tests {
.await;
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
+ editor.update(cx, |editor, cx| {
let expected_hints = vec![
"main hint #0".to_string(),
"main hint #1".to_string(),
@@ -2647,21 +2699,23 @@ pub mod tests {
);
assert_eq!(expected_hints, visible_hint_labels(editor, cx));
assert_eq!(editor.inlay_hint_cache().version, expected_hints.len(), "Every visible excerpt hints should bump the version");
- });
+ }).unwrap();
- _ = editor.update(cx, |editor, cx| {
- editor.change_selections(Some(Autoscroll::Next), cx, |s| {
- s.select_ranges([Point::new(4, 0)..Point::new(4, 0)])
- });
- editor.change_selections(Some(Autoscroll::Next), cx, |s| {
- s.select_ranges([Point::new(22, 0)..Point::new(22, 0)])
- });
- editor.change_selections(Some(Autoscroll::Next), cx, |s| {
- s.select_ranges([Point::new(50, 0)..Point::new(50, 0)])
- });
- });
+ editor
+ .update(cx, |editor, cx| {
+ editor.change_selections(Some(Autoscroll::Next), cx, |s| {
+ s.select_ranges([Point::new(4, 0)..Point::new(4, 0)])
+ });
+ editor.change_selections(Some(Autoscroll::Next), cx, |s| {
+ s.select_ranges([Point::new(22, 0)..Point::new(22, 0)])
+ });
+ editor.change_selections(Some(Autoscroll::Next), cx, |s| {
+ s.select_ranges([Point::new(50, 0)..Point::new(50, 0)])
+ });
+ })
+ .unwrap();
cx.executor().run_until_parked();
- _ = editor.update(cx, |editor, cx| {
+ editor.update(cx, |editor, cx| {
let expected_hints = vec![
"main hint #0".to_string(),
"main hint #1".to_string(),