on master help sign in
Fix goto code before merging.
commite3ec5e31ec005e33da4c848b4272e81a6d21a5f0 authorBlaž Hrastnik <blaz@mxxn.io> dateTue 16 Mar 2021, 23:05 (6 years ago) parenteadad13
2 files changed+6−8
helix-term/src/commands.rs+1−3 helix-view/src/editor.rs+5−5
helix-term/src/commands.rs+1−3
@@ -15,8 +15,6 @@ use crate::ui::{self, Popup, Prompt, PromptEvent};
1515
1616use std::path::PathBuf;
1717
18−use smol::Executor;
19−
2018use helix_view::{
2119 document::Mode,
2220 view::{View, PADDING},
@@ -853,6 +851,7 @@ pub fn exit_select_mode(cx: &mut Context) {
853851}
854852
855853fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
854+ let executor = cx.executor;
856855 let doc = cx.doc();
857856
858857 doc.mode = Mode::Normal;
@@ -876,7 +875,6 @@ fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
876875 format!("{}:{}", file, line).into()
877876 },
878877 move |editor: &mut Editor, item| {
879− let executor = smol::Executor::new();
880878 editor.open(PathBuf::from(item.uri.path()), &executor);
881879 let mut doc = &mut editor.view_mut().doc;
882880 let definition_pos = item.range.start;
helix-view/src/editor.rs+5−5
@@ -33,13 +33,13 @@ impl Editor {
3333 }
3434
3535 pub fn open(&mut self, path: PathBuf, executor: &smol::Executor) -> Result<(), Error> {
36− // TODO: try to find an open view/buffer first
37− let existing_view_option = self
36+ let existing_view = self
3837 .tree
3938 .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;
39+ .find(|(view, _)| view.doc.path() == Some(&path));
40+
41+ if let Some((view, _)) = existing_view {
42+ self.tree.focus = view.id;
4343 return Ok(());
4444 }
4545