make a start on jumping to bookmarks

pull/10905/head
Sam Vente 6 months ago
parent bb7e922ff9
commit b672490066
No known key found for this signature in database

1
Cargo.lock generated

@ -1211,6 +1211,7 @@ dependencies = [
"globset",
"hashbrown",
"helix-loader",
"helix-parsec",
"helix-stdx",
"imara-diff",
"indoc",

@ -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);

@ -334,6 +334,7 @@ pub fn default() -> HashMap<Mode, KeyTrie> {
"C-x" => decrement,
// just for debugging I'll find something better later
"1" => register_mark,
"2" => goto_mark,
});
let mut select = normal.clone();

Loading…
Cancel
Save