on master help sign in
preparing for gd merge
commiteadad13efabb6a838a366b27002e09e1d2580750 authorJan Hrastnik <jan.hrastnik2@gmail.com> dateTue 16 Mar 2021, 13:55 (6 years ago) parent4e461be
2 files changed+10−12
helix-term/src/commands.rs+1−3 helix-view/src/editor.rs+9−9
helix-term/src/commands.rs+1−3
@@ -857,8 +857,6 @@ fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
857857
858858 doc.mode = Mode::Normal;
859859
860− log::info!("{:?}", locations);
861−
862860 match locations.as_slice() {
863861 [location] => {
864862 cx.editor
@@ -874,7 +872,7 @@ fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
874872 locations,
875873 |item| {
876874 let file = item.uri.as_str();
877− let line = item.range.start.line.to_string();
875+ let line = item.range.start.line;
878876 format!("{}:{}", file, line).into()
879877 },
880878 move |editor: &mut Editor, item| {
helix-view/src/editor.rs+9−9
@@ -34,6 +34,14 @@ impl Editor {
3434
3535 pub fn open(&mut self, path: PathBuf, executor: &smol::Executor) -> Result<(), Error> {
3636 // TODO: try to find an open view/buffer first
37+ let existing_view_option = self
38+ .tree
39+ .views()
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;
43+ return Ok(());
44+ }
3745
3846 let mut doc = Document::load(path, self.theme.scopes())?;
3947
@@ -62,15 +70,7 @@ impl Editor {
6270 }
6371
6472 let view = View::new(doc)?;
65− let existing_view_option = self
66− .tree
67− .views()
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;
71− } else {
72− self.tree.insert(view);
73− }
73+ self.tree.insert(view);
7474 Ok(())
7575 }
7676