aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-29 06:29:03 +0000
committerBlaž Hrastnik2021-03-29 06:29:03 +0000
commitea407ccdba139605fbcc19ea058f68a10a9cfb86 (patch)
tree2330ea913477cc5a6d4c97013ec72a5042734fc0 /helix-term/src
parent626e49448c15f750f97e0e6e27e4d8baf21d18dc (diff)
Implement <n>g as goto line n.
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 0745c624..ecafaa1d 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1032,6 +1032,16 @@ pub fn normal_mode(cx: &mut Context) {
}
pub fn goto_mode(cx: &mut Context) {
+ let count = cx.count;
+ if count > 1 {
+ // TODO: can't go to line 1 since we can't distinguish between g and 1g, g gets converted
+ // to 1g
+ let doc = cx.doc();
+ let pos = doc.text().line_to_char(count - 1);
+ doc.set_selection(Selection::point(pos));
+ return;
+ }
+
cx.on_next_key(move |cx, event| {
if let KeyEvent {
code: KeyCode::Char(ch),