diff --git a/crates/ra_editor/src/typing.rs b/crates/ra_editor/src/typing.rs index 3ebdf153e48..97ff01e40b3 100644 --- a/crates/ra_editor/src/typing.rs +++ b/crates/ra_editor/src/typing.rs @@ -313,6 +313,62 @@ fn foo() { }"); } + #[test] + fn test_join_lines_normal_comments() { + check_join_lines(r" +fn foo() { + // Hello<|> + // world! +} +", r" +fn foo() { + // Hello<|> world! +} +"); + } + + #[test] + fn test_join_lines_doc_comments() { + check_join_lines(r" +fn foo() { + /// Hello<|> + /// world! +} +", r" +fn foo() { + /// Hello<|> world! +} +"); + } + + #[test] + fn test_join_lines_mod_comments() { + check_join_lines(r" +fn foo() { + //! Hello<|> + //! world! +} +", r" +fn foo() { + //! Hello<|> world! +} +"); + } + + #[test] + fn test_join_lines_multiline_comments() { + check_join_lines(r" +fn foo() { + // Hello<|> + /* world! */ +} +", r" +fn foo() { + // Hello<|> world! */ +} +"); + } + fn check_join_lines_sel(before: &str, after: &str) { let (sel, before) = extract_range(before); let file = File::parse(&before);