aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorJan Hrastnik2021-03-15 20:12:41 +0000
committerBlaž Hrastnik2021-03-16 14:03:29 +0000
commit4e461bea2f4cc19d0d25a62a4f278420c074b6e9 (patch)
tree1d03416b731e41f0a73e456b976ef50e220d7406 /helix-view/src
parent0828d1fdea0b69a2912bc6d550ec50c1b6bf874c (diff)
editor.open now checks if view already exists
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/editor.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index b04a07dd..38182126 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -62,7 +62,15 @@ impl Editor {
}
let view = View::new(doc)?;
- self.tree.insert(view);
+ let existing_view_option = self
+ .tree
+ .views()
+ .find(|v| view.doc.path().unwrap().to_str() == v.0.doc.path().unwrap().to_str());
+ if let Some(existing_view) = existing_view_option {
+ self.tree.focus = existing_view.0.id;
+ } else {
+ self.tree.insert(view);
+ }
Ok(())
}