on master help sign in
preparing for gd merge
eadad13Jan Hrastnik
helix-term/src/commands.rs+1−3
@@ -857,8 +857,6 @@ fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
857
857
858 doc.mode = Mode::Normal;
858 doc.mode = Mode::Normal;
859
859
860− log::info!("{:?}", locations);
861−
862 match locations.as_slice() {
860 match locations.as_slice() {
863 [location] => {
861 [location] => {
864 cx.editor
862 cx.editor
@@ -874,7 +872,7 @@ fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
874 locations,
872 locations,
875 |item| {
873 |item| {
876 let file = item.uri.as_str();
874 let file = item.uri.as_str();
877− let line = item.range.start.line.to_string();
875+ let line = item.range.start.line;
878 format!("{}:{}", file, line).into()
876 format!("{}:{}", file, line).into()
879 },
877 },
880 move |editor: &mut Editor, item| {
878 move |editor: &mut Editor, item| {
helix-view/src/editor.rs+9−9
@@ -34,6 +34,14 @@ impl Editor {
34
34
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
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+ }
37
45
38 let mut doc = Document::load(path, self.theme.scopes())?;
46 let mut doc = Document::load(path, self.theme.scopes())?;
39
47
@@ -62,15 +70,7 @@ impl Editor {
62 }
70 }
63
71
64 let view = View::new(doc)?;
72 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+ self.tree.insert(view);
73− }
74 Ok(())
74 Ok(())
75 }
75 }
76
76