Do not record keys pressed by macros while recording a macro (#12733)

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
This commit is contained in:
renshyle 2025-01-31 02:14:04 +02:00 committed by GitHub
parent 6906164177
commit 80dbe030a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 2 deletions

View file

@ -793,3 +793,30 @@ fn foo() {
Ok(())
}
#[tokio::test(flavor = "multi_thread")]
async fn macro_play_within_macro_record() -> anyhow::Result<()> {
// <https://github.com/helix-editor/helix/issues/12697>
//
// * `"aQihello<esc>Q` record a macro to register 'a' which inserts "hello"
// * `Q"aq<space>world<esc>Q` record a macro to the default macro register which plays the
// macro in register 'a' and then inserts " world"
// * `%d` clear the buffer
// * `q` replay the macro in the default macro register
// * `i<ret>` add a newline at the end
//
// The inner macro in register 'a' should replay within the outer macro exactly once to insert
// "hello world".
test((
indoc! {"\
#[|]#
"},
r#""aQihello<esc>QQ"aqi<space>world<esc>Q%dqi<ret>"#,
indoc! {"\
hello world
#[|]#"},
))
.await?;
Ok(())
}