mirror of
https://github.com/helix-editor/helix.git
synced 2025-01-19 13:37:06 +04:00
preparing for gd merge
This commit is contained in:
parent
4e461bea2f
commit
eadad13efa
@ -857,8 +857,6 @@ fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
|
||||
|
||||
doc.mode = Mode::Normal;
|
||||
|
||||
log::info!("{:?}", locations);
|
||||
|
||||
match locations.as_slice() {
|
||||
[location] => {
|
||||
cx.editor
|
||||
@ -874,7 +872,7 @@ fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
|
||||
locations,
|
||||
|item| {
|
||||
let file = item.uri.as_str();
|
||||
let line = item.range.start.line.to_string();
|
||||
let line = item.range.start.line;
|
||||
format!("{}:{}", file, line).into()
|
||||
},
|
||||
move |editor: &mut Editor, item| {
|
||||
|
@ -34,6 +34,14 @@ pub fn new(mut area: tui::layout::Rect) -> Self {
|
||||
|
||||
pub fn open(&mut self, path: PathBuf, executor: &smol::Executor) -> Result<(), Error> {
|
||||
// TODO: try to find an open view/buffer first
|
||||
let existing_view_option = self
|
||||
.tree
|
||||
.views()
|
||||
.find(|v| path.to_str().unwrap() == v.0.doc.path().unwrap().to_str().unwrap());
|
||||
if let Some(existing_view) = existing_view_option {
|
||||
self.tree.focus = existing_view.0.id;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let mut doc = Document::load(path, self.theme.scopes())?;
|
||||
|
||||
@ -62,15 +70,7 @@ pub fn open(&mut self, path: PathBuf, executor: &smol::Executor) -> Result<(), E
|
||||
}
|
||||
|
||||
let view = View::new(doc)?;
|
||||
let existing_view_option = self
|
||||
.tree
|
||||
.views()
|
||||
.find(|v| view.doc.path().unwrap().to_str() == v.0.doc.path().unwrap().to_str());
|
||||
if let Some(existing_view) = existing_view_option {
|
||||
self.tree.focus = existing_view.0.id;
|
||||
} else {
|
||||
self.tree.insert(view);
|
||||
}
|
||||
self.tree.insert(view);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user