From 1a4e94e57e181379e2ed42d63a49fbc56ed1dba4 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Mon, 29 Jun 2026 18:09:25 +0300 Subject: refactor: route tui mutations through runtime authority --- src/layout.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/layout.rs') diff --git a/src/layout.rs b/src/layout.rs index cd611d10..8a16da9c 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -206,8 +206,8 @@ impl TileLayout { } /// Set the ratio of a split node at the given path. - pub fn set_ratio_at(&mut self, path: &[bool], ratio: f32) { - set_ratio_at(&mut self.root, path, ratio.clamp(0.1, 0.9)); + pub fn set_ratio_at(&mut self, path: &[bool], ratio: f32) -> bool { + set_ratio_at(&mut self.root, path, ratio.clamp(0.1, 0.9)) } /// Adjust the nearest split in the given direction for the focused pane. @@ -577,7 +577,7 @@ fn remove_pane(node: Node, target: PaneId) -> Option { } } -fn set_ratio_at(node: &mut Node, path: &[bool], new_ratio: f32) { +fn set_ratio_at(node: &mut Node, path: &[bool], new_ratio: f32) -> bool { if let Node::Split { ratio, first, @@ -587,11 +587,14 @@ fn set_ratio_at(node: &mut Node, path: &[bool], new_ratio: f32) { { if path.is_empty() { *ratio = new_ratio; + true } else if path[0] { - set_ratio_at(second, &path[1..], new_ratio); + set_ratio_at(second, &path[1..], new_ratio) } else { - set_ratio_at(first, &path[1..], new_ratio); + set_ratio_at(first, &path[1..], new_ratio) } + } else { + false } } -- cgit v1.2.3