diff --git a/helix-term/tests/test/commands.rs b/helix-term/tests/test/commands.rs index 86ca6e68b..aec9fef73 100644 --- a/helix-term/tests/test/commands.rs +++ b/helix-term/tests/test/commands.rs @@ -653,22 +653,23 @@ async fn test_join_selections_space() -> anyhow::Result<()> { Ok(()) } +/// Comment and uncomment #[tokio::test(flavor = "multi_thread")] -async fn test_injected_comments() -> anyhow::Result<()> { +async fn test_injected_comment_tokens_simple() -> anyhow::Result<()> { // Uncomment inner injection test(( indoc! {r#"\ -

C-c on this line should use the HTML comment token(s).

+

Comment toggle on this line should use the HTML comment token(s).

"#}, - ":lang html", + ":lang html c", indoc! {r#"\ -

C-c on this line should use the HTML comment token(s).

+

Comment toggle on this line should use the HTML comment token(s).

"#}, @@ -678,37 +679,83 @@ async fn test_injected_comments() -> anyhow::Result<()> { // Comment inner injection test(( indoc! {r#"\ -

C-c on this line should use the HTML comment token(s).

+

Comment toggle on this line should use the HTML comment token(s).

"#}, - ":lang html", + ":lang html c", indoc! {r#"\ -

C-c on this line should use the HTML comment token(s).

+

Comment toggle on this line should use the HTML comment token(s).

"#}, )) .await?; - // Comments two different injection layers with different comments + // Block comment inner injection test(( indoc! {r#"\ -

C-c #[|on this line ]#should use the HTML comment token(s).

+

Comment toggle on this line should use the HTML comment token(s).

"#}, - ":lang html", + ":lang html C", indoc! {r#"\ - +

Comment toggle on this line should use the HTML comment token(s).

+ "#}, + )) + .await?; + + // Block uncomment inner injection + test(( + indoc! {r#"\ +

Comment toggle on this line should use the HTML comment token(s).

+ + "#}, + ":lang html C", + indoc! {r#"\ +

Comment toggle on this line should use the HTML comment token(s).

+ + "#}, + )) + .await?; + + Ok(()) +} + +/// Selections in different regions +#[tokio::test(flavor = "multi_thread")] +async fn test_injected_comment_tokens_multiple_selections() -> anyhow::Result<()> { + // Comments two different injection layers with different comments + test(( + indoc! {r#"\ +

Comment toggle #[|on this line ]#should use the HTML comment token(s).

+ + "#}, + ":lang html c", + indoc! {r#"\ + + "#}, @@ -718,17 +765,17 @@ async fn test_injected_comments() -> anyhow::Result<()> { // Uncomments two different injection layers with different comments test(( indoc! {r#"\ - + "#}, - ":lang html", + ":lang html c", indoc! {r#"\ -

C-c #[|on this line ]#should use the HTML comment token(s).

+

Comment toggle #[|on this line ]#should use the HTML comment token(s).

"#}, @@ -738,17 +785,17 @@ async fn test_injected_comments() -> anyhow::Result<()> { // Works with multiple selections test(( indoc! {r#"\ -

C-c #(|on this line )#should use the HTML comment token(s).

+

Comment toggle #(|on this line )#should use the HTML comment token(s).

"#}, - ":lang html", + ":lang html c", indoc! {r#"\ - + "#}, @@ -758,9 +805,9 @@ async fn test_injected_comments() -> anyhow::Result<()> { // Works with nested injection layers: html, js then css test(( indoc! {r#"\ - + "#}, - ":lang html", + ":lang html c", indoc! {r#"\ -

C-c #(|on this line)# should use the HTML comment token(s).

+

Comment toggle #(|on this line)# should use the HTML comment token(s).

+ "#}, + ":lang html C", + indoc! {r#"\ +

C-c #(|)# should use the HTML comment token(s).

+ + "#}, + )) + .await?; + Ok(()) } +/// A selection that spans across several injections takes comment tokens +/// from the injection with the bigger scope +#[tokio::test(flavor = "multi_thread")] +async fn test_injected_comment_tokens_selection_across_different_layers() -> anyhow::Result<()> { + test(( + indoc! {r#"\ +

Comment tog#[|gle on this line should use the HTML comment token(s).

+ + "#}, + ":lang html c", + indoc! {r#"\ + + + + foo(); + + "#}, + )) + .await?; + test(( + indoc! {r#"\ +

Comment tog#[|gle on this line should use the HTML comment token(s).

+ + "#}, + ":lang html C", + indoc! {r#"\ +

Comment tog#[|]#le on this line should use the javascript comment token(s). + foo(); + + "#}, + )) + .await?; +} + #[tokio::test(flavor = "multi_thread")] async fn test_join_selections_comment() -> anyhow::Result<()> { test(( diff --git a/lol.html b/lol.html index 0e60e6725..18f6aa519 100644 --- a/lol.html +++ b/lol.html @@ -1,10 +1,5 @@ - +

C-c on this line should use the HTML comment token(s).