@@ -13,7 +13,6 @@ use once_cell::sync::Lazy;
13use crate::compositor::Compositor;
13use crate::compositor::Compositor;
14use crate::ui::{self, Popup, Prompt, PromptEvent};
14use crate::ui::{self, Popup, Prompt, PromptEvent};
17use std::path::PathBuf;
16use std::path::PathBuf;
19use smol::Executor;
18use smol::Executor;
@@ -26,6 +25,8 @@ use helix_view::{
27use crossterm::event::{KeyCode, KeyEvent};
26use crossterm::event::{KeyCode, KeyEvent};
29pub struct Context<'a> {
30pub struct Context<'a> {
30 pub count: usize,
31 pub count: usize,
31 pub editor: &'a mut Editor,
32 pub editor: &'a mut Editor,
@@ -851,16 +852,16 @@ pub fn exit_select_mode(cx: &mut Context) {
851 cx.doc().mode = Mode::Normal;
852 cx.doc().mode = Mode::Normal;
854−pub fn goto_generic(cx: &mut Context, res: Vec<lsp::Location>) {
855+fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
855 let doc = cx.doc();
856 let doc = cx.doc();
857 doc.mode = Mode::Normal;
858 doc.mode = Mode::Normal;
859− log::info!("{:?}", res);
860+ log::info!("{:?}", locations);
860 let filepath = doc.path().unwrap();
861 let filepath = doc.path().unwrap();
861 log::info!("{:?}", filepath);
862 log::info!("{:?}", filepath);
863− match &res.as_slice() {
864+ match locations.as_slice() {
864 [location] => {
865 [location] => {
865 if filepath.to_str().unwrap() == location.uri.path() {
866 if filepath.to_str().unwrap() == location.uri.path() {
866 let definition_pos = location.range.start;
867 let definition_pos = location.range.start;
@@ -874,10 +875,9 @@ pub fn goto_generic(cx: &mut Context, res: Vec<lsp::Location>) {
876 [] => (), // maybe show user message that no definition was found?
877 [] => (), // maybe show user message that no definition was found?
877− _ => {
878+ _locations => {
878− let snapshot = doc.state.clone();
879 let mut picker = ui::Picker::new(
879 let mut picker = ui::Picker::new(
882 let file = item.uri.as_str();
882 let file = item.uri.as_str();
883 let line = item.range.start.line.to_string();
883 let line = item.range.start.line.to_string();
@@ -885,9 +885,6 @@ pub fn goto_generic(cx: &mut Context, res: Vec<lsp::Location>) {
886 move |editor: &mut Editor, item| {
886 move |editor: &mut Editor, item| {
887 let doc = &mut editor.view_mut().doc;
887 let doc = &mut editor.view_mut().doc;
889− // revert state to what it was before the last update
890− doc.state = snapshot.clone();
@@ -907,7 +904,7 @@ pub fn goto_definition(cx: &mut Context) {
907 // TODO: handle fails
904 // TODO: handle fails
908 let res =
905 let res =
909 smol::block_on(language_server.goto_definition(doc.identifier(), pos)).unwrap_or_default();
906 smol::block_on(language_server.goto_definition(doc.identifier(), pos)).unwrap_or_default();
910− goto_generic(cx, res);
907+ goto(cx, res);
913pub fn goto_type_definition(cx: &mut Context) {
910pub fn goto_type_definition(cx: &mut Context) {
@@ -923,7 +920,7 @@ pub fn goto_type_definition(cx: &mut Context) {
923 // TODO: handle fails
920 // TODO: handle fails
924 let res = smol::block_on(language_server.goto_type_definition(doc.identifier(), pos))
921 let res = smol::block_on(language_server.goto_type_definition(doc.identifier(), pos))
925 .unwrap_or_default();
922 .unwrap_or_default();
926− goto_generic(cx, res);
923+ goto(cx, res);
929pub fn goto_implementation(cx: &mut Context) {
926pub fn goto_implementation(cx: &mut Context) {
@@ -939,7 +936,7 @@ pub fn goto_implementation(cx: &mut Context) {
939 // TODO: handle fails
936 // TODO: handle fails
940 let res = smol::block_on(language_server.goto_implementation(doc.identifier(), pos))
937 let res = smol::block_on(language_server.goto_implementation(doc.identifier(), pos))
941 .unwrap_or_default();
938 .unwrap_or_default();
942− goto_generic(cx, res);
939+ goto(cx, res);
945pub fn goto_reference(cx: &mut Context) {
942pub fn goto_reference(cx: &mut Context) {
@@ -955,7 +952,7 @@ pub fn goto_reference(cx: &mut Context) {
955 // TODO: handle fails
952 // TODO: handle fails
956 let res =
953 let res =
957 smol::block_on(language_server.goto_reference(doc.identifier(), pos)).unwrap_or_default();
954 smol::block_on(language_server.goto_reference(doc.identifier(), pos)).unwrap_or_default();
958− goto_generic(cx, res);
955+ goto(cx, res);
961// NOTE: Transactions in this module get appended to history when we switch back to normal mode.
958// NOTE: Transactions in this module get appended to history when we switch back to normal mode.