Fix flaky test_highlighted_ranges
due to random TypeId
ordering
This commit is contained in:
parent
74e5c5b89a
commit
ae5aebf405
2 changed files with 17 additions and 13 deletions
|
@ -7279,20 +7279,16 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
let snapshot = editor.snapshot(cx);
|
let snapshot = editor.snapshot(cx);
|
||||||
assert_eq!(
|
let mut highlighted_ranges = editor.highlighted_ranges_in_range(
|
||||||
editor.highlighted_ranges_in_range(
|
|
||||||
anchor_range(Point::new(3, 4)..Point::new(7, 4)),
|
anchor_range(Point::new(3, 4)..Point::new(7, 4)),
|
||||||
&snapshot,
|
&snapshot,
|
||||||
),
|
);
|
||||||
|
// Enforce a consistent ordering based on color without relying on the ordering of the
|
||||||
|
// highlight's `TypeId` which is non-deterministic.
|
||||||
|
highlighted_ranges.sort_unstable_by_key(|(_, color)| *color);
|
||||||
|
assert_eq!(
|
||||||
|
highlighted_ranges,
|
||||||
&[
|
&[
|
||||||
(
|
|
||||||
DisplayPoint::new(4, 2)..DisplayPoint::new(4, 4),
|
|
||||||
Color::red(),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
DisplayPoint::new(6, 3)..DisplayPoint::new(6, 5),
|
|
||||||
Color::red(),
|
|
||||||
),
|
|
||||||
(
|
(
|
||||||
DisplayPoint::new(3, 2)..DisplayPoint::new(3, 5),
|
DisplayPoint::new(3, 2)..DisplayPoint::new(3, 5),
|
||||||
Color::green(),
|
Color::green(),
|
||||||
|
@ -7301,6 +7297,14 @@ mod tests {
|
||||||
DisplayPoint::new(5, 3)..DisplayPoint::new(5, 6),
|
DisplayPoint::new(5, 3)..DisplayPoint::new(5, 6),
|
||||||
Color::green(),
|
Color::green(),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
DisplayPoint::new(4, 2)..DisplayPoint::new(4, 4),
|
||||||
|
Color::red(),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
DisplayPoint::new(6, 3)..DisplayPoint::new(6, 5),
|
||||||
|
Color::red(),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -12,7 +12,7 @@ use serde::{
|
||||||
};
|
};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Default, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Color(ColorU);
|
pub struct Color(ColorU);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue