Format Rust sources at 100 columns

This commit is contained in:
Samuel Onoja committed 2026-10-22 01:28:03 +01:00
1 parent 4661f595f8
commit 610478f8c7
336 files changed
+23497 -7892

No files matched your search

+243 -68
View File
@@ -4,7 +4,9 @@ use std::fmt;
mod scrolling;
pub use scrolling::{Column, ColumnDisplay, ColumnWidth, ScrollingLayout, ViewportFocusStrategy, ViewportTarget};
pub use scrolling::{
Column, ColumnDisplay, ColumnWidth, ScrollingLayout, ViewportFocusStrategy, ViewportTarget,
};
pub const TAB_BAR_HEIGHT: f64 = 24.0;
@@ -68,7 +70,12 @@ pub struct Rect {
impl Rect {
pub const fn new(x: f64, y: f64, width: f64, height: f64) -> Self {
Self { x, y, width, height }
Self {
x,
y,
width,
height,
}
}
fn center(self) -> (f64, f64) {
@@ -184,8 +191,12 @@ impl LayoutTree {
fn count(tree: &LayoutTree, node: NodeId) -> usize {
match tree.nodes.get(&node) {
Some(Node::Window(_)) => 1,
Some(Node::Split { first, second, .. }) => count(tree, *first) + count(tree, *second),
Some(Node::Stack { children, active }) => children.get(*active).map_or(0, |child| count(tree, *child)),
Some(Node::Split { first, second, .. }) => {
count(tree, *first) + count(tree, *second)
}
Some(Node::Stack { children, active }) => {
children.get(*active).map_or(0, |child| count(tree, *child))
}
None => 0,
}
}
@@ -208,7 +219,11 @@ impl LayoutTree {
if let Some(root) = self.root {
self.collect_window_positions(root, bounds, &mut windows)?;
}
windows.sort_by(|(_, left), (_, right)| left.x.total_cmp(&right.x).then_with(|| left.y.total_cmp(&right.y)));
windows.sort_by(|(_, left), (_, right)| {
left.x
.total_cmp(&right.x)
.then_with(|| left.y.total_cmp(&right.y))
});
Ok(windows.into_iter().map(|(window, _)| window).collect())
}
@@ -420,7 +435,11 @@ impl LayoutTree {
}
pub fn tab_groups(&self) -> Vec<TabGroup> {
let mut groups: Vec<_> = self.nodes.keys().filter_map(|id| self.group_at(*id)).collect();
let mut groups: Vec<_> = self
.nodes
.keys()
.filter_map(|id| self.group_at(*id))
.collect();
groups.sort_by_key(|group| group.windows[0].0);
groups
}
@@ -482,7 +501,11 @@ impl LayoutTree {
Ok(geometry)
}
pub fn geometry_with_gaps(&self, bounds: Rect, gaps: GapConfig) -> Result<HashMap<WindowId, Rect>, LayoutError> {
pub fn geometry_with_gaps(
&self,
bounds: Rect,
gaps: GapConfig,
) -> Result<HashMap<WindowId, Rect>, LayoutError> {
let mut geometry = self.geometry(bounds)?;
apply_gaps(&mut geometry, bounds, gaps);
@@ -547,7 +570,11 @@ impl LayoutTree {
Ok(result)
}
pub fn automatic_axis(&self, focused: Option<WindowId>, bounds: Rect) -> Result<Axis, LayoutError> {
pub fn automatic_axis(
&self,
focused: Option<WindowId>,
bounds: Rect,
) -> Result<Axis, LayoutError> {
let Some(root) = self.root else {
return Ok(Axis::Horizontal);
};
@@ -625,7 +652,12 @@ impl LayoutTree {
.map(|(candidate, _, _, _)| candidate))
}
pub fn move_window(&mut self, window: WindowId, direction: Direction, bounds: Rect) -> Result<bool, LayoutError> {
pub fn move_window(
&mut self,
window: WindowId,
direction: Direction,
bounds: Rect,
) -> Result<bool, LayoutError> {
let Some(neighbor) = self.directional_neighbor(window, direction, bounds)? else {
return Ok(false);
};
@@ -649,7 +681,12 @@ impl LayoutTree {
Ok(true)
}
pub fn resize_window(&mut self, window: WindowId, direction: Direction, amount: f64) -> Result<bool, LayoutError> {
pub fn resize_window(
&mut self,
window: WindowId,
direction: Direction,
amount: f64,
) -> Result<bool, LayoutError> {
let mut child = self
.windows
.get(&window)
@@ -778,7 +815,9 @@ impl LayoutTree {
match self.nodes.get(&node) {
Some(Node::Window(_)) => Ok(node),
Some(Node::Split { first, .. }) => self.first_window(*first),
Some(Node::Stack { children, active, .. }) => children
Some(Node::Stack {
children, active, ..
}) => children
.get(*active)
.copied()
.ok_or(LayoutError::InvalidTree("stack active index is invalid"))
@@ -787,7 +826,12 @@ impl LayoutTree {
}
}
fn replace_child(&mut self, parent: NodeId, old: NodeId, new: NodeId) -> Result<(), LayoutError> {
fn replace_child(
&mut self,
parent: NodeId,
old: NodeId,
new: NodeId,
) -> Result<(), LayoutError> {
match self.nodes.get_mut(&parent) {
Some(Node::Split { first, .. }) if *first == old => *first = new,
Some(Node::Split { second, .. }) if *second == old => *second = new,
@@ -804,7 +848,12 @@ impl LayoutTree {
Ok(())
}
fn collapse_parent(&mut self, parent: NodeId, leaf: NodeId, sibling: NodeId) -> Result<(), LayoutError> {
fn collapse_parent(
&mut self,
parent: NodeId,
leaf: NodeId,
sibling: NodeId,
) -> Result<(), LayoutError> {
let window = match self.nodes.get(&leaf) {
Some(Node::Window(window)) => *window,
_ => return Err(LayoutError::InvalidTree("removed leaf is not a window")),
@@ -901,11 +950,21 @@ impl LayoutTree {
} else {
(available - second_required).max(0.0)
};
let adjusted_ratio = if available > 0.0 { first_extent / available } else { 0.5 };
let adjusted_ratio = if available > 0.0 {
first_extent / available
} else {
0.5
};
let (first_bounds, second_bounds) = split_rect(bounds, *axis, adjusted_ratio);
self.layout_node_constrained(*first, first_bounds, constraints, focused, geometry)?;
self.layout_node_constrained(*second, second_bounds, constraints, focused, geometry)?;
self.layout_node_constrained(
*second,
second_bounds,
constraints,
focused,
geometry,
)?;
}
Some(Node::Stack { children, active }) => {
let child = children
@@ -931,7 +990,10 @@ impl LayoutTree {
Ok((constraint.min_width, constraint.min_height))
}
Some(Node::Split {
axis, first, second, ..
axis,
first,
second,
..
}) => {
let first = self.minimum_size(*first, constraints)?;
let second = self.minimum_size(*second, constraints)?;
@@ -962,7 +1024,9 @@ impl LayoutTree {
Some(Node::Split { first, second, .. }) => {
self.contains_window(*first, window) || self.contains_window(*second, window)
}
Some(Node::Stack { children, .. }) => children.iter().any(|child| self.contains_window(*child, window)),
Some(Node::Stack { children, .. }) => children
.iter()
.any(|child| self.contains_window(*child, window)),
None => false,
}
}
@@ -987,9 +1051,15 @@ impl LayoutTree {
}
}
Some(Node::Split {
ratio, first, second, ..
ratio,
first,
second,
..
}) => {
if first == second || !ratio.is_finite() || !(MIN_SPLIT_RATIO..=MAX_SPLIT_RATIO).contains(ratio) {
if first == second
|| !ratio.is_finite()
|| !(MIN_SPLIT_RATIO..=MAX_SPLIT_RATIO).contains(ratio)
{
return Err(LayoutError::InvalidTree("split is invalid"));
}
@@ -1025,7 +1095,11 @@ fn valid_gap(gap: f64) -> f64 {
}
fn valid_resize_amount(amount: f64) -> f64 {
if amount.is_finite() { amount.abs() } else { 0.0 }
if amount.is_finite() {
amount.abs()
} else {
0.0
}
}
fn normalized_constraints(constraints: SizeConstraints) -> SizeConstraints {
@@ -1119,7 +1193,12 @@ fn nearly_equal(left: f64, right: f64) -> bool {
(left - right).abs() < f64::EPSILON * left.abs().max(right.abs()).max(1.0)
}
fn intervals_overlap(first_start: f64, first_size: f64, second_start: f64, second_size: f64) -> bool {
fn intervals_overlap(
first_start: f64,
first_size: f64,
second_start: f64,
second_size: f64,
) -> bool {
first_start < second_start + second_size && second_start < first_start + first_size
}
@@ -1128,14 +1207,24 @@ fn split_rect(bounds: Rect, axis: Axis, ratio: f64) -> (Rect, Rect) {
Axis::Horizontal => {
let boundary = bounds.x + bounds.width * ratio;
let first = Rect::new(bounds.x, bounds.y, boundary - bounds.x, bounds.height);
let second = Rect::new(boundary, bounds.y, bounds.x + bounds.width - boundary, bounds.height);
let second = Rect::new(
boundary,
bounds.y,
bounds.x + bounds.width - boundary,
bounds.height,
);
(first, second)
}
Axis::Vertical => {
let boundary = bounds.y + bounds.height * ratio;
let first = Rect::new(bounds.x, bounds.y, bounds.width, boundary - bounds.y);
let second = Rect::new(bounds.x, boundary, bounds.width, bounds.y + bounds.height - boundary);
let second = Rect::new(
bounds.x,
boundary,
bounds.width,
bounds.y + bounds.height - boundary,
);
(first, second)
}
@@ -1149,32 +1238,43 @@ mod tests {
#[test]
fn insertion_splits_the_focused_leaf() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(3), Some(WindowId(1)), Axis::Vertical, 0.5)
.unwrap();
assert!(tree.validate().is_ok());
assert_eq!(tree.geometry(Rect::new(0.0, 0.0, 100.0, 80.0)).unwrap().len(), 3);
assert_eq!(
tree.geometry(Rect::new(0.0, 0.0, 100.0, 80.0))
.unwrap()
.len(),
3
);
}
#[test]
fn removal_collapses_the_parent_split() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
tree.remove(WindowId(1)).unwrap();
assert!(tree.validate().is_ok());
assert_eq!(tree.node(tree.root().unwrap()), Some(&Node::Window(WindowId(2))));
assert_eq!(
tree.node(tree.root().unwrap()),
Some(&Node::Window(WindowId(2)))
);
}
#[test]
fn shared_split_boundary_is_exact() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 1.0 / 3.0).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 1.0 / 3.0)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 1.0 / 3.0)
.unwrap();
@@ -1189,7 +1289,8 @@ mod tests {
#[test]
fn rejects_duplicate_and_unknown_windows() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
assert_eq!(
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5),
@@ -1210,20 +1311,28 @@ mod tests {
#[test]
fn automatic_axis_follows_focused_tile_shape() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
let wide = Rect::new(0.0, 0.0, 1_920.0, 1_080.0);
assert_eq!(tree.automatic_axis(Some(WindowId(1)), wide).unwrap(), Axis::Horizontal);
assert_eq!(
tree.automatic_axis(Some(WindowId(1)), wide).unwrap(),
Axis::Horizontal
);
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
assert_eq!(tree.automatic_axis(Some(WindowId(1)), wide).unwrap(), Axis::Vertical);
assert_eq!(
tree.automatic_axis(Some(WindowId(1)), wide).unwrap(),
Axis::Vertical
);
}
#[test]
fn gaps_preserve_outer_and_shared_spacing() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
@@ -1241,7 +1350,8 @@ mod tests {
#[test]
fn smart_gaps_remove_outer_gap_for_one_window() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
let bounds = Rect::new(0.0, 0.0, 100.0, 80.0);
let geometry = tree
@@ -1260,7 +1370,8 @@ mod tests {
#[test]
fn default_gaps_keep_outer_spacing_for_one_window() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
let geometry = tree
.geometry_with_gaps(Rect::new(0.0, 0.0, 100.0, 80.0), GapConfig::default())
@@ -1272,7 +1383,8 @@ mod tests {
#[test]
fn directional_neighbor_prefers_primary_distance() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(3), Some(WindowId(2)), Axis::Vertical, 0.5)
@@ -1285,11 +1397,13 @@ mod tests {
Some(WindowId(2))
);
assert_eq!(
tree.directional_neighbor(WindowId(2), Direction::Down, bounds).unwrap(),
tree.directional_neighbor(WindowId(2), Direction::Down, bounds)
.unwrap(),
Some(WindowId(3))
);
assert_eq!(
tree.directional_neighbor(WindowId(1), Direction::Left, bounds).unwrap(),
tree.directional_neighbor(WindowId(1), Direction::Left, bounds)
.unwrap(),
None
);
}
@@ -1297,12 +1411,16 @@ mod tests {
#[test]
fn directional_move_swaps_window_leaves() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
let bounds = Rect::new(0.0, 0.0, 100.0, 80.0);
assert!(tree.move_window(WindowId(1), Direction::Right, bounds).unwrap());
assert!(
tree.move_window(WindowId(1), Direction::Right, bounds)
.unwrap()
);
let geometry = tree.geometry(bounds).unwrap();
assert_eq!(geometry[&WindowId(2)].x, 0.0);
@@ -1313,11 +1431,16 @@ mod tests {
#[test]
fn directional_move_at_boundary_is_a_noop() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
assert!(
!tree
.move_window(WindowId(1), Direction::Left, Rect::new(0.0, 0.0, 100.0, 80.0),)
.move_window(
WindowId(1),
Direction::Left,
Rect::new(0.0, 0.0, 100.0, 80.0),
)
.unwrap()
);
}
@@ -1325,14 +1448,18 @@ mod tests {
#[test]
fn directional_resize_changes_the_nearest_matching_split() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(3), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
let bounds = Rect::new(0.0, 0.0, 100.0, 100.0);
assert!(tree.resize_window(WindowId(1), Direction::Right, 0.1).unwrap());
assert!(
tree.resize_window(WindowId(1), Direction::Right, 0.1)
.unwrap()
);
let geometry = tree.geometry(bounds).unwrap();
assert_eq!(geometry[&WindowId(1)].width, 30.0);
@@ -1344,15 +1471,23 @@ mod tests {
#[test]
fn directional_resize_walks_to_an_ancestor_and_clamps() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(3), Some(WindowId(1)), Axis::Vertical, 0.5)
.unwrap();
let bounds = Rect::new(0.0, 0.0, 100.0, 100.0);
assert!(tree.resize_window(WindowId(3), Direction::Right, 1.0).unwrap());
assert!(!tree.resize_window(WindowId(3), Direction::Right, 1.0).unwrap());
assert!(
tree.resize_window(WindowId(3), Direction::Right, 1.0)
.unwrap()
);
assert!(
!tree
.resize_window(WindowId(3), Direction::Right, 1.0)
.unwrap()
);
let geometry = tree.geometry(bounds).unwrap();
assert_eq!(geometry[&WindowId(2)].x, 95.0);
@@ -1362,16 +1497,26 @@ mod tests {
#[test]
fn directional_resize_at_an_outer_edge_is_a_noop() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
assert!(!tree.resize_window(WindowId(1), Direction::Left, 0.05).unwrap());
assert!(!tree.resize_window(WindowId(1), Direction::Right, f64::NAN).unwrap());
assert!(
!tree
.resize_window(WindowId(1), Direction::Left, 0.05)
.unwrap()
);
assert!(
!tree
.resize_window(WindowId(1), Direction::Right, f64::NAN)
.unwrap()
);
}
#[test]
fn stacking_windows_shows_only_the_active_child() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
tree.stack_window(WindowId(2), WindowId(1)).unwrap();
@@ -1388,14 +1533,19 @@ mod tests {
let ids = [WindowId(30), WindowId(10), WindowId(20), WindowId(5)];
tree.insert(ids[0], None, Axis::Horizontal, 0.5).unwrap();
for pair in ids.windows(2) {
tree.insert(pair[1], Some(pair[0]), Axis::Horizontal, 0.5).unwrap();
tree.insert(pair[1], Some(pair[0]), Axis::Horizontal, 0.5)
.unwrap();
tree.stack_window(pair[1], pair[0]).unwrap();
}
let bounds = Rect::new(0.0, 0.0, 1_000.0, 800.0);
for active in ids {
tree.activate_window(active).unwrap();
assert_eq!(
tree.geometry(bounds).unwrap().keys().copied().collect::<Vec<_>>(),
tree.geometry(bounds)
.unwrap()
.keys()
.copied()
.collect::<Vec<_>>(),
vec![active]
);
assert_eq!(tree.window_ids_in_reading_order(bounds).unwrap(), ids);
@@ -1434,7 +1584,8 @@ mod tests {
#[test]
fn structural_reading_order_retains_xy_order_through_splits_and_stacks() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(40), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(40), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(10), Some(WindowId(40)), Axis::Vertical, 0.5)
.unwrap();
tree.insert(WindowId(30), Some(WindowId(40)), Axis::Horizontal, 0.5)
@@ -1461,8 +1612,13 @@ mod tests {
fn tree_preference_follows_first_split_branch_and_active_stack_children() {
let mut tree = LayoutTree::default();
assert_eq!(tree.preferred_window(), None);
assert!(tree.window_ids_in_reading_order(Rect::default()).unwrap().is_empty());
tree.insert(WindowId(30), None, Axis::Horizontal, 0.5).unwrap();
assert!(
tree.window_ids_in_reading_order(Rect::default())
.unwrap()
.is_empty()
);
tree.insert(WindowId(30), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(10), Some(WindowId(30)), Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(20), Some(WindowId(30)), Axis::Vertical, 0.5)
@@ -1478,7 +1634,8 @@ mod tests {
#[test]
fn activating_a_hidden_stack_child_changes_visible_geometry() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
tree.stack_window(WindowId(2), WindowId(1)).unwrap();
@@ -1493,7 +1650,8 @@ mod tests {
#[test]
fn removing_from_a_stack_collapses_or_preserves_cardinality() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
tree.stack_window(WindowId(2), WindowId(1)).unwrap();
@@ -1503,7 +1661,10 @@ mod tests {
tree.remove(WindowId(3)).unwrap();
tree.remove(WindowId(2)).unwrap();
assert_eq!(tree.node(tree.root().unwrap()), Some(&Node::Window(WindowId(1))));
assert_eq!(
tree.node(tree.root().unwrap()),
Some(&Node::Window(WindowId(1)))
);
assert!(tree.validate().is_ok());
}
@@ -1516,7 +1677,9 @@ mod tests {
let bounds = Rect::new(0.0, 0.0, 1_920.0, 1_080.0);
for _ in 0..2_000 {
random = random.wrapping_mul(6_364_136_223_846_793_005).wrapping_add(1);
random = random
.wrapping_mul(6_364_136_223_846_793_005)
.wrapping_add(1);
let operation = random % 6;
match operation {
@@ -1530,7 +1693,8 @@ mod tests {
Axis::Vertical
};
tree.insert(window, focused, axis, ratio_from_random(random)).unwrap();
tree.insert(window, focused, axis, ratio_from_random(random))
.unwrap();
windows.push(window);
}
1 if !windows.is_empty() => {
@@ -1557,7 +1721,8 @@ mod tests {
}
5 if !windows.is_empty() => {
let window = windows[random as usize % windows.len()];
tree.resize_window(window, random_direction(random), 0.03).unwrap();
tree.resize_window(window, random_direction(random), 0.03)
.unwrap();
}
_ => {}
}
@@ -1569,7 +1734,8 @@ mod tests {
#[test]
fn constraints_adjust_split_boundaries_when_space_is_available() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.2).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.2)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.2)
.unwrap();
let constraints = HashMap::from([
@@ -1609,7 +1775,8 @@ mod tests {
#[test]
fn focused_window_wins_an_impossible_minimum_constraint_conflict() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.5)
.unwrap();
let constraints = HashMap::from([
@@ -1651,7 +1818,8 @@ mod tests {
#[test]
fn maximum_constraints_clip_without_overlapping_neighbors() {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
let constraints = HashMap::from([(
WindowId(1),
SizeConstraints {
@@ -1669,7 +1837,10 @@ mod tests {
)
.unwrap();
assert_eq!(result.geometry[&WindowId(1)], Rect::new(4.0, 4.0, 60.0, 40.0));
assert_eq!(
result.geometry[&WindowId(1)],
Rect::new(4.0, 4.0, 60.0, 40.0)
);
assert_eq!(result.warnings.len(), 2);
}
@@ -1697,7 +1868,8 @@ mod tab_tests {
fn nested() -> LayoutTree {
let mut tree = LayoutTree::default();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5).unwrap();
tree.insert(WindowId(1), None, Axis::Horizontal, 0.5)
.unwrap();
tree.insert(WindowId(2), Some(WindowId(1)), Axis::Horizontal, 0.6)
.unwrap();
tree.insert(WindowId(3), Some(WindowId(1)), Axis::Vertical, 0.4)
@@ -1727,7 +1899,10 @@ mod tab_tests {
assert_eq!(tree.adjacent_tab(WindowId(3), true), Some(WindowId(1)));
assert!(tree.leave_tab_group(WindowId(1)).unwrap());
assert_eq!(tree.geometry(bounds).unwrap()[&WindowId(2)], neighbor);
assert_eq!(tree.tab_group(WindowId(4)).unwrap().windows, [WindowId(3), WindowId(4)]);
assert_eq!(
tree.tab_group(WindowId(4)).unwrap().windows,
[WindowId(3), WindowId(4)]
);
assert!(tree.tab_group(WindowId(1)).is_none());
assert!(!tree.leave_tab_group(WindowId(1)).unwrap());
tree.remove(WindowId(4)).unwrap();
File diff suppressed because it is too large. Load diff