diff options
author | Blaž Hrastnik | 2021-03-29 07:32:42 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-03-29 07:32:42 +0000 |
commit | 742b3a709fd7680d77bcda5ae08f2a9539b6a20e (patch) | |
tree | 38589e2b87ea31ee879bc48da3c5381830ad7e5c /helix-term/src/commands.rs | |
parent | 0083a6c325d5bb9dc33a43e5b3d727bde0d7990b (diff) |
Store intra-files jumps (goto) on the jumplist.
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r-- | helix-term/src/commands.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index ddee8b93..d2aa481a 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -238,11 +238,13 @@ pub fn move_next_word_end(cx: &mut Context) { } pub fn move_file_start(cx: &mut Context) { + push_jump(cx); let doc = cx.doc(); doc.set_selection(Selection::point(0)); } pub fn move_file_end(cx: &mut Context) { + push_jump(cx); let doc = cx.doc(); let text = doc.text(); let last_line = text.line_to_char(text.len_lines().saturating_sub(2)); @@ -1027,9 +1029,21 @@ pub fn normal_mode(cx: &mut Context) { } } +// Store a jump on the jumplist. +fn push_jump(cx: &mut Context) { + let jump = { + let doc = cx.doc(); + (doc.id(), doc.selection().clone()) + }; + cx.view().jumps.push(jump); +} + pub fn goto_mode(cx: &mut Context) { let count = cx.count; + if count > 1 { + push_jump(cx); + // 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(); @@ -1069,6 +1083,8 @@ pub fn exit_select_mode(cx: &mut Context) { fn _goto(cx: &mut Context, locations: Vec<lsp::Location>) { use helix_view::editor::Action; + push_jump(cx); + fn jump_to(editor: &mut Editor, location: &lsp::Location, action: Action) { let id = editor .open(PathBuf::from(location.uri.path()), action) |