Skip to content

Commit fd3e889

Browse files
the-mikedavisarchseer
authored andcommitted
Add integration tests for line comment continuation
1 parent 1e6fe00 commit fd3e889

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

helix-term/tests/test/commands/insert.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,71 @@ async fn insert_newline_trim_trailing_whitespace() -> anyhow::Result<()> {
5151

5252
Ok(())
5353
}
54+
55+
#[tokio::test(flavor = "multi_thread")]
56+
async fn insert_newline_continue_line_comment() -> anyhow::Result<()> {
57+
// `insert_newline` continues a single line comment
58+
test((
59+
indoc! {"\
60+
// Hello world!#[|
61+
]#
62+
"},
63+
":lang rust<ret>i<ret>",
64+
indoc! {"\
65+
// Hello world!
66+
// #[|
67+
]#
68+
"},
69+
))
70+
.await?;
71+
72+
// The comment is not continued if the cursor is before the comment token. (Note that we
73+
// are entering insert-mode with `I`.)
74+
test((
75+
indoc! {"\
76+
// Hello world!#[|
77+
]#
78+
"},
79+
":lang rust<ret>I<ret>",
80+
indoc! {"\
81+
\n#[/|]#/ Hello world!
82+
"},
83+
))
84+
.await?;
85+
86+
// `insert_newline` again clears the whitespace on the first continued comment and continues
87+
// the comment again.
88+
test((
89+
indoc! {"\
90+
// Hello world!
91+
// #[|
92+
]#
93+
"},
94+
":lang rust<ret>i<ret>",
95+
indoc! {"\
96+
// Hello world!
97+
//
98+
// #[|
99+
]#
100+
"},
101+
))
102+
.await?;
103+
104+
// Line comment continuation and trailing whitespace is also trimmed when using
105+
// `insert_newline` in the middle of a comment.
106+
test((
107+
indoc! {"\
108+
//·hello····#[|·]#····world
109+
"}
110+
.replace('·', " "),
111+
":lang rust<ret>i<ret>",
112+
indoc! {"\
113+
//·hello
114+
//·#[|·]#····world
115+
"}
116+
.replace('·', " "),
117+
))
118+
.await?;
119+
120+
Ok(())
121+
}

0 commit comments

Comments
 (0)