aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/editor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src/editor.rs')
-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..5c94df27 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -33,7 +33,15 @@ 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 = self
+ .tree
+ .views()
+ .find(|(view, _)| view.doc.path() == Some(&path));
+
+ if let Some((view, _)) = existing_view {
+ self.tree.focus = view.id;
+ return Ok(());
+ }
let mut doc = Document::load(path, self.theme.scopes())?;