mirror of https://github.com/helix-editor/helix
Simplify code a bit.
parent
8a68a04340
commit
18ec8adc7f
|
@ -847,25 +847,21 @@ pub fn exit_select_mode(cx: &mut Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn goto_definition(cx: &mut Context) {
|
pub fn goto_definition(cx: &mut Context) {
|
||||||
let language_server = cx
|
|
||||||
.editor
|
|
||||||
.language_servers
|
|
||||||
.get("source.rust", &cx.executor)
|
|
||||||
.unwrap();
|
|
||||||
use log::info;
|
|
||||||
|
|
||||||
let doc = cx.doc();
|
let doc = cx.doc();
|
||||||
|
|
||||||
|
let language_server = match doc.language_server.as_ref() {
|
||||||
|
Some(language_server) => language_server,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
|
||||||
// TODO: blocking here is not ideal
|
// TODO: blocking here is not ideal
|
||||||
let pos = helix_lsp::util::pos_to_lsp_pos(doc.text().slice(..), doc.selection().cursor());
|
let pos = helix_lsp::util::pos_to_lsp_pos(doc.text().slice(..), doc.selection().cursor());
|
||||||
|
|
||||||
// TODO: handle fails
|
// TODO: handle fails
|
||||||
let res = smol::block_on(language_server.goto_definition(cx.doc().identifier(), pos))
|
let res =
|
||||||
.unwrap_or_default();
|
smol::block_on(language_server.goto_definition(doc.identifier(), pos)).unwrap_or_default();
|
||||||
|
|
||||||
println!("{:?}", res);
|
doc.mode = Mode::Normal;
|
||||||
|
|
||||||
cx.doc().mode = Mode::Normal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Transactions in this module get appended to history when we switch back to normal mode.
|
// NOTE: Transactions in this module get appended to history when we switch back to normal mode.
|
||||||
|
|
Loading…
Reference in New Issue