diff --git a/Cargo.lock b/Cargo.lock index 7e4ebbb8f..c33e0720e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1211,6 +1211,7 @@ dependencies = [ "globset", "hashbrown", "helix-loader", + "helix-parsec", "helix-stdx", "imara-diff", "indoc", diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 8a70b4b49..7c215910f 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -568,6 +568,7 @@ impl MappableCommand { goto_word, "Jump to a two-character label", extend_to_word, "Extend to a two-character label", register_mark, "Register a bookmark", + goto_mark, "Goto a bookmark", ); } @@ -6123,6 +6124,32 @@ fn extend_to_word(cx: &mut Context) { jump_to_word(cx, Movement::Extend) } +pub fn goto_mark(cx: &mut Context) { + let register_name = cx.register.unwrap_or('^').clone(); + let register_content = cx.editor.registers.read(register_name, cx.editor); + let res = match register_content { + Some(values) => values + .into_iter() + .next() + .map(|c| c.into_owned()) + .map(|s| { + let mut split_iter = s.split(":").into_iter(); + let doc_id = split_iter.next().unwrap(); + let range_tupel = split_iter.next().unwrap(); + log::debug!("doc id: {:?}", &doc_id); + log::debug!("range_tuple: {:?}", &range_tupel); + }) + .ok_or(format!( + "Register {} did not contain anything", + register_name + )), + None => Err(format!( + "Register {} did not contain anything", + register_name + )), + }; +} + fn register_mark(cx: &mut Context) { let register_name = cx.register.unwrap_or('^').clone(); let (view, doc) = current!(cx.editor); diff --git a/helix-term/src/keymap/default.rs b/helix-term/src/keymap/default.rs index ee503826d..615731d08 100644 --- a/helix-term/src/keymap/default.rs +++ b/helix-term/src/keymap/default.rs @@ -334,6 +334,7 @@ pub fn default() -> HashMap { "C-x" => decrement, // just for debugging I'll find something better later "1" => register_mark, + "2" => goto_mark, }); let mut select = normal.clone();