|
|
@ -1,5 +1,7 @@
|
|
|
|
use helix_core::{
|
|
|
|
use helix_core::{
|
|
|
|
comment, coords_at_pos, find_first_non_whitespace_char, find_root, graphemes, indent,
|
|
|
|
comment, coords_at_pos, find_first_non_whitespace_char, find_root, graphemes,
|
|
|
|
|
|
|
|
history::UndoKind,
|
|
|
|
|
|
|
|
indent,
|
|
|
|
indent::IndentStyle,
|
|
|
|
indent::IndentStyle,
|
|
|
|
line_ending::{get_line_ending_of_str, line_end_char_index, str_is_line_ending},
|
|
|
|
line_ending::{get_line_ending_of_str, line_end_char_index, str_is_line_ending},
|
|
|
|
match_brackets,
|
|
|
|
match_brackets,
|
|
|
@ -284,6 +286,8 @@ impl Command {
|
|
|
|
delete_word_backward, "Delete previous word",
|
|
|
|
delete_word_backward, "Delete previous word",
|
|
|
|
undo, "Undo change",
|
|
|
|
undo, "Undo change",
|
|
|
|
redo, "Redo change",
|
|
|
|
redo, "Redo change",
|
|
|
|
|
|
|
|
earlier, "Move backward in history",
|
|
|
|
|
|
|
|
later, "Move forward in history",
|
|
|
|
yank, "Yank selection",
|
|
|
|
yank, "Yank selection",
|
|
|
|
yank_joined_to_clipboard, "Join and yank selections to clipboard",
|
|
|
|
yank_joined_to_clipboard, "Join and yank selections to clipboard",
|
|
|
|
yank_main_selection_to_clipboard, "Yank main selection to clipboard",
|
|
|
|
yank_main_selection_to_clipboard, "Yank main selection to clipboard",
|
|
|
@ -1877,10 +1881,7 @@ mod cmd {
|
|
|
|
args: &[&str],
|
|
|
|
args: &[&str],
|
|
|
|
_event: PromptEvent,
|
|
|
|
_event: PromptEvent,
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
let uk = args
|
|
|
|
let uk = args.join(" ").parse::<UndoKind>().map_err(|s| anyhow!(s))?;
|
|
|
|
.join(" ")
|
|
|
|
|
|
|
|
.parse::<helix_core::history::UndoKind>()
|
|
|
|
|
|
|
|
.map_err(|s| anyhow!(s))?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let (view, doc) = current!(cx.editor);
|
|
|
|
let (view, doc) = current!(cx.editor);
|
|
|
|
let success = doc.earlier(view.id, uk);
|
|
|
|
let success = doc.earlier(view.id, uk);
|
|
|
@ -1896,10 +1897,7 @@ mod cmd {
|
|
|
|
args: &[&str],
|
|
|
|
args: &[&str],
|
|
|
|
_event: PromptEvent,
|
|
|
|
_event: PromptEvent,
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
let uk = args
|
|
|
|
let uk = args.join(" ").parse::<UndoKind>().map_err(|s| anyhow!(s))?;
|
|
|
|
.join(" ")
|
|
|
|
|
|
|
|
.parse::<helix_core::history::UndoKind>()
|
|
|
|
|
|
|
|
.map_err(|s| anyhow!(s))?;
|
|
|
|
|
|
|
|
let (view, doc) = current!(cx.editor);
|
|
|
|
let (view, doc) = current!(cx.editor);
|
|
|
|
let success = doc.later(view.id, uk);
|
|
|
|
let success = doc.later(view.id, uk);
|
|
|
|
if !success {
|
|
|
|
if !success {
|
|
|
@ -3963,20 +3961,48 @@ pub mod insert {
|
|
|
|
// storing it?
|
|
|
|
// storing it?
|
|
|
|
|
|
|
|
|
|
|
|
fn undo(cx: &mut Context) {
|
|
|
|
fn undo(cx: &mut Context) {
|
|
|
|
|
|
|
|
let count = cx.count();
|
|
|
|
let (view, doc) = current!(cx.editor);
|
|
|
|
let (view, doc) = current!(cx.editor);
|
|
|
|
let view_id = view.id;
|
|
|
|
for _ in 0..count {
|
|
|
|
let success = doc.undo(view_id);
|
|
|
|
if !doc.undo(view.id) {
|
|
|
|
if !success {
|
|
|
|
cx.editor.set_status("Already at oldest change".to_owned());
|
|
|
|
cx.editor.set_status("Already at oldest change".to_owned());
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn redo(cx: &mut Context) {
|
|
|
|
fn redo(cx: &mut Context) {
|
|
|
|
|
|
|
|
let count = cx.count();
|
|
|
|
|
|
|
|
let (view, doc) = current!(cx.editor);
|
|
|
|
|
|
|
|
for _ in 0..count {
|
|
|
|
|
|
|
|
if !doc.redo(view.id) {
|
|
|
|
|
|
|
|
cx.editor.set_status("Already at newest change".to_owned());
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn earlier(cx: &mut Context) {
|
|
|
|
|
|
|
|
let count = cx.count();
|
|
|
|
|
|
|
|
let (view, doc) = current!(cx.editor);
|
|
|
|
|
|
|
|
for _ in 0..count {
|
|
|
|
|
|
|
|
// rather than doing in batch we do this so get error halfway
|
|
|
|
|
|
|
|
if !doc.earlier(view.id, UndoKind::Steps(1)) {
|
|
|
|
|
|
|
|
cx.editor.set_status("Already at oldest change".to_owned());
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn later(cx: &mut Context) {
|
|
|
|
|
|
|
|
let count = cx.count();
|
|
|
|
let (view, doc) = current!(cx.editor);
|
|
|
|
let (view, doc) = current!(cx.editor);
|
|
|
|
let view_id = view.id;
|
|
|
|
for _ in 0..count {
|
|
|
|
let success = doc.redo(view_id);
|
|
|
|
// rather than doing in batch we do this so get error halfway
|
|
|
|
if !success {
|
|
|
|
if !doc.later(view.id, UndoKind::Steps(1)) {
|
|
|
|
cx.editor.set_status("Already at newest change".to_owned());
|
|
|
|
cx.editor.set_status("Already at newest change".to_owned());
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|