on master help sign in
Implement <n>g as goto line n.
ea407ccBlaž Hrastnik
helix-term/src/commands.rs+10
@@ -1032,6 +1032,16 @@ pub fn normal_mode(cx: &mut Context) {
1032}
1032}
1033
1033
1034pub fn goto_mode(cx: &mut Context) {
1034pub fn goto_mode(cx: &mut Context) {
1035+ let count = cx.count;
1036+ if count > 1 {
1037+ // TODO: can't go to line 1 since we can't distinguish between g and 1g, g gets converted
1038+ // to 1g
1039+ let doc = cx.doc();
1040+ let pos = doc.text().line_to_char(count - 1);
1041+ doc.set_selection(Selection::point(pos));
1042+ return;
1043+ }
1044+
1035 cx.on_next_key(move |cx, event| {
1045 cx.on_next_key(move |cx, event| {
1036 if let KeyEvent {
1046 if let KeyEvent {
1037 code: KeyCode::Char(ch),
1047 code: KeyCode::Char(ch),