aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-16 14:09:04 +0000
committerGitHub2021-03-16 14:09:04 +0000
commit8dc0b18e35cdfdd76f435dcd43c1cfd5a3f0c7f7 (patch)
treea26c6025d45658b4d85d6917ea82489d6ba8fb2e /helix-view/src
parentd8599f3a140eca7cd14f47e9b64f1ae9d829a0eb (diff)
parente3ec5e31ec005e33da4c848b4272e81a6d21a5f0 (diff)
Merge pull request #8 from helix-editor/gd
Goto
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..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())?;