Commit 91957f0ae29e
tarball2 files changed+19-2
@@ -261,3 +261,19 @@ fn moving_toward_a_hidden_lane_joins_it() {
261261
assert!(rect(d).x < rect(e).x);262262
assert!(rect(a).y < rect(d).y);263263
}264
+265
+#[test]266
+fn merging_past_the_last_lane_leaves_the_stack() {267
+ let (a, b, c) = (1, 2, 3);268
+ let mut t: Tree<u32> = Tree::default();269
+ t.insert_row(a);270
+ t.insert_after(b, a);271
+ t.insert_after(c, b);272
+ assert!(t.merge_window(b, Dir::Left, |_| true));273
+ assert!(t.merge_window(a, Dir::Up, |_| true));274
+ t.check();275
+ let all = t.arrange(AREA, 0.0, |_| true);276
+ let rect = |w| all.iter().find(|p| p.0 == w).unwrap().1;277
+ assert_eq!(rect(a).w, AREA.w);278
+ assert!(rect(a).bottom() <= rect(b).y && rect(b).y == rect(c).y);279
+}@@ -200,7 +200,8 @@ impl<W: Copy + Eq + Hash> Tree<W> {
200200
201201
/// Moves a window to the end of the next visible lane in `dir`, stepping202202
/// up a level when its container has none that way. A lone window there203
- /// becomes a stack with it.203
+ /// becomes a stack with it. With no lane anywhere that way, it leaves its204
+ /// stack as `move_window` would.204205
pub fn merge_window(&mut self, w: W, dir: Dir, vis: impl Fn(W) -> bool) -> bool {205206
let Some(&n) = self.leaves.get(&w) else {206207
return false;@@ -215,7 +216,7 @@ impl<W: Copy + Eq + Hash> Tree<W> {
215216
}216217
cur = p;217218
}218
- false219
+ self.move_node(n, dir, &vis, true)219220
}220221
221222
/// Whether every container above `w` is expanded towards it.