aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs16
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)