summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-04-13 07:56:03 +0000
committerBlaž Hrastnik2021-04-13 07:56:03 +0000
commit2a1f10d1b57f88233eb48a9dbce2b56196801bd8 (patch)
tree2e177ba2f8524295243e98df0e016a29a91ba6de
parent95dd55ba943f3667bac3acecb2c65ee7f69d42cd (diff)
Center the new position on screen after doing a goto jump.
-rw-r--r--helix-term/src/commands.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index d75cb6ff..f1c5f8b5 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1122,6 +1122,8 @@ fn _goto(cx: &mut Context, locations: Vec<lsp::Location>) {
let definition_pos = location.range.start;
let new_pos = lsp_pos_to_pos(doc.text(), definition_pos);
doc.set_selection(view.id, Selection::point(new_pos));
+ let line = doc.text().char_to_line(new_pos);
+ view.first_line = line.saturating_sub(view.area.height as usize / 2);
}
match locations.as_slice() {