aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands/lsp.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-06-06 15:19:01 +0000
committerBlaž Hrastnik2022-06-06 15:23:41 +0000
commit26dbdb70fb29bdad2e875a776b70815bf5533a34 (patch)
treef4fe1db8fd1a0a06b83e5cb5102ccb5bf1e9ec6b /helix-term/src/commands/lsp.rs
parent3d9923969afb56be03b87a6a1cc47c486bead66b (diff)
Refactor push_jump so we're not needlessly fetching doc twice
Diffstat (limited to 'helix-term/src/commands/lsp.rs')
-rw-r--r--helix-term/src/commands/lsp.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index 8f139b3b..93ae2353 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -39,13 +39,15 @@ fn location_to_file_location(location: &lsp::Location) -> FileLocation {
}
// TODO: share with symbol picker(symbol.location)
-// TODO: need to use push_jump() before?
fn jump_to_location(
editor: &mut Editor,
location: &lsp::Location,
offset_encoding: OffsetEncoding,
action: Action,
) {
+ let (view, doc) = current!(editor);
+ push_jump(view, doc);
+
let path = match location.uri.to_file_path() {
Ok(path) => path,
Err(_) => {
@@ -93,9 +95,10 @@ fn sym_picker(
}
},
move |cx, symbol, action| {
- if current_path2.as_ref() == Some(&symbol.location.uri) {
- push_jump(cx.editor);
- } else {
+ let (view, doc) = current!(cx.editor);
+ push_jump(view, doc);
+
+ if current_path2.as_ref() != Some(&symbol.location.uri) {
let uri = &symbol.location.uri;
let path = match uri.to_file_path() {
Ok(path) => path,
@@ -518,7 +521,6 @@ fn goto_impl(
format!("{}:{}", file, line).into()
},
move |cx, location, action| {
- push_jump(cx.editor);
jump_to_location(cx.editor, location, offset_encoding, action)
},
move |_editor, location| Some(location_to_file_location(location)),