From 3da08bca620ec3958e564ed89268864048407e85 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Mon, 13 May 2024 08:39:43 -0700 Subject: [PATCH] Fixed a crash in Switcher I'm not sure exactly what caused this that other simpler cases were not, but essentially nodes were already removed once by the time this loop is evaluated, so we can skip adding them back to the list again. --- CHANGELOG.md | 5 +++++ src/tree.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f137bc3..dd0f3c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Fixed + +- Fixed a panic that could occur when removing some deeply nested hierarchies + from a window. + ### Added - `AnimationRecorder::animate_keypress` is a new helper that animates a single diff --git a/src/tree.rs b/src/tree.rs index 9de8bb0..dde860a 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -506,7 +506,7 @@ impl TreeData { removed_node .children .into_iter() - .map(|id| self.nodes[id].widget.id()), + .filter_map(|id| self.nodes.get(id).map(|node| node.widget.id())), ); if let Some(next_focus) = removed_node.widget.next_focus() {