From 445fa0bd3a7470bbf31ada5405b772934da88f19 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Mon, 4 Sep 2023 06:18:45 +0200 Subject: [PATCH] tree nav: rename get_max_depth() to get_height() --- nested/src/editors/typeterm/mod.rs | 4 ++-- nested/src/tree/nav.rs | 2 +- nested/src/tree/node.rs | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/nested/src/editors/typeterm/mod.rs b/nested/src/editors/typeterm/mod.rs index 109cfce..a7f51fa 100644 --- a/nested/src/editors/typeterm/mod.rs +++ b/nested/src/editors/typeterm/mod.rs @@ -483,8 +483,8 @@ impl TreeNav for TypeTermEditor { self.cur_node.get().get_cursor_warp() } - fn get_max_depth(&self) -> usize { - self.cur_node.get().get_max_depth() + fn get_height(&self) -> usize { + self.cur_node.get().get_height() } fn goby(&mut self, dir: Vector2) -> TreeNavResult { diff --git a/nested/src/tree/nav.rs b/nested/src/tree/nav.rs index c525065..2997276 100644 --- a/nested/src/tree/nav.rs +++ b/nested/src/tree/nav.rs @@ -59,7 +59,7 @@ pub trait TreeNav { TreeCursor::default() } - fn get_max_depth(&self) -> usize { + fn get_height(&self) -> usize { 0 } diff --git a/nested/src/tree/node.rs b/nested/src/tree/node.rs index 348b204..6956289 100644 --- a/nested/src/tree/node.rs +++ b/nested/src/tree/node.rs @@ -304,8 +304,12 @@ impl TreeNav for NestedNode { } } - fn get_max_depth(&self) -> usize { - 0 + fn get_height(&self) -> usize { + if let Some(tn) = self.tree_nav.get() { + tn.read().unwrap().get_height() + } else { + 0 + } } fn goby(&mut self, direction: Vector2) -> TreeNavResult {