@@ -34,6 +34,14 @@ impl Editor {
35 pub fn open(&mut self, path: PathBuf, executor: &smol::Executor) -> Result<(), Error> {
35 pub fn open(&mut self, path: PathBuf, executor: &smol::Executor) -> Result<(), Error> {
36 // TODO: try to find an open view/buffer first
36 // TODO: try to find an open view/buffer first
37+ let existing_view_option = self
40+ .find(|v| path.to_str().unwrap() == v.0.doc.path().unwrap().to_str().unwrap());
41+ if let Some(existing_view) = existing_view_option {
42+ self.tree.focus = existing_view.0.id;
38 let mut doc = Document::load(path, self.theme.scopes())?;
46 let mut doc = Document::load(path, self.theme.scopes())?;
@@ -62,15 +70,7 @@ impl Editor {
64 let view = View::new(doc)?;
72 let view = View::new(doc)?;
65− let existing_view_option = self
68− .find(|v| view.doc.path().unwrap().to_str() == v.0.doc.path().unwrap().to_str());
69− if let Some(existing_view) = existing_view_option {
70− self.tree.focus = existing_view.0.id;
72− self.tree.insert(view);
73+ self.tree.insert(view);