@@ -1,5 +1,7 @@
1use helix_core::{
1use helix_core::{
2− comment, coords_at_pos, find_first_non_whitespace_char, find_root, graphemes, indent,
2+ comment, coords_at_pos, find_first_non_whitespace_char, find_root, graphemes,
3 indent::IndentStyle,
5 indent::IndentStyle,
4 line_ending::{get_line_ending_of_str, line_end_char_index, str_is_line_ending},
6 line_ending::{get_line_ending_of_str, line_end_char_index, str_is_line_ending},
5 match_brackets,
7 match_brackets,
@@ -284,6 +286,8 @@ impl Command {
284 delete_word_backward, "Delete previous word",
286 delete_word_backward, "Delete previous word",
285 undo, "Undo change",
287 undo, "Undo change",
286 redo, "Redo change",
288 redo, "Redo change",
289+ earlier, "Move backward in history",
290+ later, "Move forward in history",
287 yank, "Yank selection",
291 yank, "Yank selection",
288 yank_joined_to_clipboard, "Join and yank selections to clipboard",
292 yank_joined_to_clipboard, "Join and yank selections to clipboard",
289 yank_main_selection_to_clipboard, "Yank main selection to clipboard",
293 yank_main_selection_to_clipboard, "Yank main selection to clipboard",
@@ -1877,10 +1881,7 @@ mod cmd {
1877 args: &[&str],
1881 args: &[&str],
1878 _event: PromptEvent,
1882 _event: PromptEvent,
1879 ) -> anyhow::Result<()> {
1883 ) -> anyhow::Result<()> {
1882− .parse::<helix_core::history::UndoKind>()
1883− .map_err(|s| anyhow!(s))?;
1884+ let uk = args.join(" ").parse::<UndoKind>().map_err(|s| anyhow!(s))?;
1885 let (view, doc) = current!(cx.editor);
1886 let (view, doc) = current!(cx.editor);
1886 let success = doc.earlier(view.id, uk);
1887 let success = doc.earlier(view.id, uk);
@@ -1896,10 +1897,7 @@ mod cmd {
1896 args: &[&str],
1897 args: &[&str],
1897 _event: PromptEvent,
1898 _event: PromptEvent,
1898 ) -> anyhow::Result<()> {
1899 ) -> anyhow::Result<()> {
1901− .parse::<helix_core::history::UndoKind>()
1902− .map_err(|s| anyhow!(s))?;
1900+ let uk = args.join(" ").parse::<UndoKind>().map_err(|s| anyhow!(s))?;
1903 let (view, doc) = current!(cx.editor);
1901 let (view, doc) = current!(cx.editor);
1904 let success = doc.later(view.id, uk);
1902 let success = doc.later(view.id, uk);
1905 if !success {
1903 if !success {
@@ -3963,20 +3961,48 @@ pub mod insert {
3963// storing it?
3961// storing it?
3965fn undo(cx: &mut Context) {
3963fn undo(cx: &mut Context) {
3964+ let count = cx.count();
3966 let (view, doc) = current!(cx.editor);
3965 let (view, doc) = current!(cx.editor);
3967− let view_id = view.id;
3966+ for _ in 0..count {
3968− let success = doc.undo(view_id);
3967+ if !doc.undo(view.id) {
3970− cx.editor.set_status("Already at oldest change".to_owned());
3968+ cx.editor.set_status("Already at oldest change".to_owned());
3974fn redo(cx: &mut Context) {
3974fn redo(cx: &mut Context) {
3975+ let count = cx.count();
3976+ let (view, doc) = current!(cx.editor);
3977+ for _ in 0..count {
3978+ if !doc.redo(view.id) {
3979+ cx.editor.set_status("Already at newest change".to_owned());
3985+fn earlier(cx: &mut Context) {
3986+ let count = cx.count();
3987+ let (view, doc) = current!(cx.editor);
3988+ for _ in 0..count {
3989+ // rather than doing in batch we do this so get error halfway
3990+ if !doc.earlier(view.id, UndoKind::Steps(1)) {
3991+ cx.editor.set_status("Already at oldest change".to_owned());
3997+fn later(cx: &mut Context) {
3998+ let count = cx.count();
3975 let (view, doc) = current!(cx.editor);
3999 let (view, doc) = current!(cx.editor);
3976− let view_id = view.id;
4000+ for _ in 0..count {
3977− let success = doc.redo(view_id);
4001+ // rather than doing in batch we do this so get error halfway
3978− if !success {
4002+ if !doc.later(view.id, UndoKind::Steps(1)) {
3979− cx.editor.set_status("Already at newest change".to_owned());
4003+ cx.editor.set_status("Already at newest change".to_owned());