mirror of https://github.com/helix-editor/helix
Append changes to history on jumps (#13619)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>pull/11700/merge
parent
c9e7b0f84f
commit
7dcddf98c6
|
@ -3762,7 +3762,8 @@ fn normal_mode(cx: &mut Context) {
|
|||
}
|
||||
|
||||
// Store a jump on the jumplist.
|
||||
fn push_jump(view: &mut View, doc: &Document) {
|
||||
fn push_jump(view: &mut View, doc: &mut Document) {
|
||||
doc.append_changes_to_history(view);
|
||||
let jump = (doc.id(), doc.selection(view.id).clone());
|
||||
view.jumps.push(jump);
|
||||
}
|
||||
|
|
|
@ -534,3 +534,40 @@ async fn try_restore_indent() -> anyhow::Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Tests being able to jump in insert mode, then undo the write performed by the jump
|
||||
// https://github.com/helix-editor/helix/issues/13480
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_jump_undo_redo() -> anyhow::Result<()> {
|
||||
use helix_core::hashmap;
|
||||
use helix_term::keymap;
|
||||
use helix_view::document::Mode;
|
||||
|
||||
let mut config = Config::default();
|
||||
config.keys.insert(
|
||||
Mode::Insert,
|
||||
keymap!({"Insert Mode"
|
||||
"C-i" => goto_file_start,
|
||||
"C-o" => goto_file_end,
|
||||
}),
|
||||
);
|
||||
|
||||
// Undo
|
||||
test_with_config(
|
||||
AppBuilder::new().with_config(config.clone()),
|
||||
("#[|]#", "iworld<C-i>Hello, <esc>u", "#[w|]#orld"),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Redo
|
||||
test_with_config(
|
||||
AppBuilder::new().with_config(config),
|
||||
(
|
||||
"#[|]#",
|
||||
"iworld<C-i>Hello, <esc>ui<C-o><esc>U",
|
||||
"Hello, #[w|]#orld",
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue