summaryrefslogtreecommitdiff
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.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 07034214..3cb1288e 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -980,6 +980,30 @@ mod cmd {
doc.format(view.id)
}
+ fn earlier(editor: &mut Editor, args: &[&str], event: PromptEvent) {
+ let uk = match args.join(" ").parse::<helix_core::history::UndoKind>() {
+ Ok(uk) => uk,
+ Err(msg) => {
+ editor.set_error(msg);
+ return;
+ }
+ };
+ let (view, doc) = editor.current();
+ doc.earlier(view.id, uk)
+ }
+
+ fn later(editor: &mut Editor, args: &[&str], event: PromptEvent) {
+ let uk = match args.join(" ").parse::<helix_core::history::UndoKind>() {
+ Ok(uk) => uk,
+ Err(msg) => {
+ editor.set_error(msg);
+ return;
+ }
+ };
+ let (view, doc) = editor.current();
+ doc.later(view.id, uk)
+ }
+
pub const COMMAND_LIST: &[Command] = &[
Command {
name: "quit",
@@ -1023,6 +1047,20 @@ mod cmd {
fun: format,
completer: None,
},
+ Command {
+ name: "earlier",
+ alias: Some("ear"),
+ doc: "Jump back to an earlier point in edit history. Accepts a number of steps or a time span.",
+ fun: earlier,
+ completer: None,
+ },
+ Command {
+ name: "later",
+ alias: Some("lat"),
+ doc: "Jump to a later point in edit history. Accepts a number of steps or a time span.",
+ fun: later,
+ completer: None,
+ },
];
pub static COMMANDS: Lazy<HashMap<&'static str, &'static Command>> = Lazy::new(|| {