From 26dbdb70fb29bdad2e875a776b70815bf5533a34 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Tue, 7 Jun 2022 00:19:01 +0900 Subject: Refactor push_jump so we're not needlessly fetching doc twice --- helix-term/src/commands/lsp.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'helix-term/src/commands') 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)), -- cgit v1.2.3-70-g09d2