aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-29 07:32:42 +0000
committerBlaž Hrastnik2021-03-29 07:32:42 +0000
commit742b3a709fd7680d77bcda5ae08f2a9539b6a20e (patch)
tree38589e2b87ea31ee879bc48da3c5381830ad7e5c /helix-term/src
parent0083a6c325d5bb9dc33a43e5b3d727bde0d7990b (diff)
Store intra-files jumps (goto) on the jumplist.
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs16
-rw-r--r--helix-term/src/keymap.rs1
-rw-r--r--helix-term/src/ui/mod.rs2
3 files changed, 18 insertions, 1 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)
diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs
index f401f0f9..d7a72377 100644
--- a/helix-term/src/keymap.rs
+++ b/helix-term/src/keymap.rs
@@ -258,6 +258,7 @@ pub fn default() -> Keymaps {
ctrl!('i') => commands::jump_forward, // TODO: ctrl-i conflicts tab
ctrl!('o') => commands::jump_backward,
+ // ctrl!('s') => commands::save_selection,
);
// TODO: decide whether we want normal mode to also be select mode (kakoune-like), or whether
// we keep this separate select mode. More keys can fit into normal mode then, but it's weird
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index 8cb82fcb..0e38e598 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -49,7 +49,7 @@ pub fn regex_prompt(
doc.set_selection(snapshot.clone());
}
PromptEvent::Validate => {
- //
+ // TODO: push_jump to store selection just before jump
}
PromptEvent::Update => {
// skip empty input, TODO: trigger default