From 2a1f10d1b57f88233eb48a9dbce2b56196801bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Tue, 13 Apr 2021 16:56:03 +0900 Subject: [PATCH] Center the new position on screen after doing a goto jump. --- helix-term/src/commands.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index d75cb6ff9..f1c5f8b5a 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1122,6 +1122,8 @@ fn _goto(cx: &mut Context, locations: Vec) { 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() {