Better assert multibuffer edit test results
This commit is contained in:
parent
4b3273182a
commit
e0d011e354
1 changed files with 13 additions and 7 deletions
|
@ -1901,6 +1901,8 @@ mod tests {
|
||||||
});
|
});
|
||||||
|
|
||||||
let visible_range_after_scrolls = editor_visible_range(&editor, cx);
|
let visible_range_after_scrolls = editor_visible_range(&editor, cx);
|
||||||
|
let visible_line_count =
|
||||||
|
editor.update(cx, |editor, _| editor.visible_line_count().unwrap());
|
||||||
cx.foreground().run_until_parked();
|
cx.foreground().run_until_parked();
|
||||||
let selection_in_cached_range = editor.update(cx, |editor, cx| {
|
let selection_in_cached_range = editor.update(cx, |editor, cx| {
|
||||||
let ranges = lsp_request_ranges
|
let ranges = lsp_request_ranges
|
||||||
|
@ -1923,12 +1925,11 @@ mod tests {
|
||||||
first_scroll.start, expected_initial_query_range_end,
|
first_scroll.start, expected_initial_query_range_end,
|
||||||
"First scroll should start the query right after the end of the original scroll",
|
"First scroll should start the query right after the end of the original scroll",
|
||||||
);
|
);
|
||||||
let expected_increment = editor.visible_line_count().unwrap().ceil() as u32;
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
second_scroll.end,
|
second_scroll.end,
|
||||||
lsp::Position::new(
|
lsp::Position::new(
|
||||||
visible_range_after_scrolls.end.row
|
visible_range_after_scrolls.end.row
|
||||||
+ expected_increment,
|
+ visible_line_count.ceil() as u32,
|
||||||
0
|
0
|
||||||
),
|
),
|
||||||
"Second scroll should query one more screen down after the end of the visible range"
|
"Second scroll should query one more screen down after the end of the visible range"
|
||||||
|
@ -1953,12 +1954,12 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut selection_in_cached_range = visible_range_after_scrolls.end;
|
let mut selection_in_cached_range = visible_range_after_scrolls.end;
|
||||||
selection_in_cached_range.row -= expected_increment;
|
selection_in_cached_range.row -= visible_line_count.ceil() as u32;
|
||||||
selection_in_cached_range
|
selection_in_cached_range
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.update(cx, |editor, cx| {
|
editor.update(cx, |editor, cx| {
|
||||||
editor.change_selections(Some(Autoscroll::Next), cx, |s| {
|
editor.change_selections(Some(Autoscroll::center()), cx, |s| {
|
||||||
s.select_ranges([selection_in_cached_range..selection_in_cached_range])
|
s.select_ranges([selection_in_cached_range..selection_in_cached_range])
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1979,12 +1980,17 @@ mod tests {
|
||||||
cx.foreground().run_until_parked();
|
cx.foreground().run_until_parked();
|
||||||
editor.update(cx, |editor, cx| {
|
editor.update(cx, |editor, cx| {
|
||||||
let ranges = lsp_request_ranges.lock().drain(..).collect::<Vec<_>>();
|
let ranges = lsp_request_ranges.lock().drain(..).collect::<Vec<_>>();
|
||||||
let expected_increment = editor.visible_line_count().unwrap().ceil() as u32;
|
|
||||||
assert_eq!(ranges.len(), 1,
|
assert_eq!(ranges.len(), 1,
|
||||||
"On edit, should scroll to selection and query a range around it. Instead, got query ranges {ranges:?}");
|
"On edit, should scroll to selection and query a range around it. Instead, got query ranges {ranges:?}");
|
||||||
let query_range = &ranges[0];
|
let query_range = &ranges[0];
|
||||||
assert_eq!(query_range.start, lsp::Position::new(selection_in_cached_range.row - expected_increment, 0));
|
assert!(query_range.start.line < selection_in_cached_range.row,
|
||||||
assert_eq!(query_range.end, lsp::Position::new(selection_in_cached_range.row + expected_increment, 0));
|
"Hints should be queried with the selected range after the query range start");
|
||||||
|
assert!(query_range.end.line > selection_in_cached_range.row,
|
||||||
|
"Hints should be queried with the selected range before the query range end");
|
||||||
|
assert!(query_range.start.line <= selection_in_cached_range.row - (visible_line_count * 3.0 / 2.0) as u32,
|
||||||
|
"Hints query range should contain one more screen before");
|
||||||
|
assert!(query_range.end.line >= selection_in_cached_range.row + (visible_line_count * 3.0 / 2.0) as u32,
|
||||||
|
"Hints query range should contain one more screen after");
|
||||||
|
|
||||||
assert_eq!(lsp_request_count.load(Ordering::Acquire), 4, "Should query for hints once after the edit");
|
assert_eq!(lsp_request_count.load(Ordering::Acquire), 4, "Should query for hints once after the edit");
|
||||||
let expected_layers = vec!["4".to_string()];
|
let expected_layers = vec!["4".to_string()];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue