aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
authorJan Hrastnik2021-03-16 12:55:12 +0000
committerBlaž Hrastnik2021-03-16 14:03:29 +0000
commiteadad13efabb6a838a366b27002e09e1d2580750 (patch)
tree6dc04d20559c26e82af457cd830ee5386839b346 /helix-view
parent4e461bea2f4cc19d0d25a62a4f278420c074b6e9 (diff)
preparing for gd merge
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/editor.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 38182126..99c0398f 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -34,6 +34,14 @@ impl Editor {
pub fn open(&mut self, path: PathBuf, executor: &smol::Executor) -> Result<(), Error> {
// TODO: try to find an open view/buffer first
+ let existing_view_option = self
+ .tree
+ .views()
+ .find(|v| path.to_str().unwrap() == v.0.doc.path().unwrap().to_str().unwrap());
+ if let Some(existing_view) = existing_view_option {
+ self.tree.focus = existing_view.0.id;
+ return Ok(());
+ }
let mut doc = Document::load(path, self.theme.scopes())?;
@@ -62,15 +70,7 @@ impl Editor {
}
let view = View::new(doc)?;
- 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);
- }
+ self.tree.insert(view);
Ok(())
}