aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/tree.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src/tree.rs')
-rw-r--r--helix-view/src/tree.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/helix-view/src/tree.rs b/helix-view/src/tree.rs
index 5ec2773d..e8afd204 100644
--- a/helix-view/src/tree.rs
+++ b/helix-view/src/tree.rs
@@ -278,16 +278,15 @@ impl Tree {
self.try_get(index).unwrap()
}
- /// Try to get reference to a [View] by index. Returns `None` if node content is not a [Content::View]
- /// # Panics
+ /// Try to get reference to a [View] by index. Returns `None` if node content is not a [`Content::View`].
///
- /// Panics if `index` is not in self.nodes. This can be checked with [Self::contains]
+ /// Does not panic if the view does not exists anymore.
pub fn try_get(&self, index: ViewId) -> Option<&View> {
- match &self.nodes[index] {
- Node {
+ match self.nodes.get(index) {
+ Some(Node {
content: Content::View(view),
..
- } => Some(view),
+ }) => Some(view),
_ => None,
}
}