on master help sign in
Implement gt/gm/gb, remap goto tYpe to gy
4f0e3aaBlaž Hrastnik
book/src/keymap.md+4−1
@@ -118,8 +118,11 @@ Jumps to various locations.
118|-----|-----------|
118|-----|-----------|
119| g | Go to the start of the file |
119| g | Go to the start of the file |
120| e | Go to the end of the file |
120| e | Go to the end of the file |
121+| t | Go to the top of the screen |
122+| m | Go to the middle of the screen |
123+| b | Go to the bottom of the screen |
121| d | Go to definition |
124| d | Go to definition |
122−| t | Go to type definition |
125+| y | Go to type definition |
123| r | Go to references |
126| r | Go to references |
124| i | Go to implementation |
127| i | Go to implementation |
125
128
helix-term/src/commands.rs+24−1
@@ -1270,9 +1270,32 @@ pub fn goto_mode(cx: &mut Context) {
1270 'g' => move_file_start(cx),
1270 'g' => move_file_start(cx),
1271 'e' => move_file_end(cx),
1271 'e' => move_file_end(cx),
1272 'd' => goto_definition(cx),
1272 'd' => goto_definition(cx),
1273− 't' => goto_type_definition(cx),
1273+ 'y' => goto_type_definition(cx),
1274 'r' => goto_reference(cx),
1274 'r' => goto_reference(cx),
1275 'i' => goto_implementation(cx),
1275 'i' => goto_implementation(cx),
1276+
1277+ 't' | 'm' | 'b' => {
1278+ let (view, doc) = cx.current();
1279+
1280+ let pos = doc.selection(view.id).cursor();
1281+ let line = doc.text().char_to_line(pos);
1282+
1283+ let scrolloff = PADDING.min(view.area.height as usize / 2); // TODO: user pref
1284+
1285+ let last_line = view.last_line(doc);
1286+
1287+ let line = match ch {
1288+ 't' => (view.first_line + scrolloff),
1289+ 'm' => (view.first_line + (view.area.height as usize / 2)),
1290+ 'b' => last_line.saturating_sub(scrolloff),
1291+ _ => unreachable!(),
1292+ }
1293+ .min(last_line.saturating_sub(scrolloff));
1294+
1295+ let pos = doc.text().line_to_char(line);
1296+
1297+ doc.set_selection(view.id, Selection::point(pos));
1298+ }
1276 _ => (),
1299 _ => (),
1277 }
1300 }
1278 }
1301 }