From 6fe77db41307da8ead8a0b0355488221b61c0349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Ochagav=C3=ADa?= Date: Thu, 11 Oct 2018 17:16:12 +0200 Subject: Remove smart multiline comment join --- crates/ra_editor/src/typing.rs | 45 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'crates') diff --git a/crates/ra_editor/src/typing.rs b/crates/ra_editor/src/typing.rs index 97ff01e40..1dc658f9b 100644 --- a/crates/ra_editor/src/typing.rs +++ b/crates/ra_editor/src/typing.rs @@ -174,27 +174,10 @@ fn remove_newline( ); } else if let (Some(_), Some(next)) = (ast::Comment::cast(prev), ast::Comment::cast(next)) { // Removes: newline (incl. surrounding whitespace), start of the next comment - let comment_text = next.text(); - if let Some(newline_pos) = comment_text.find('\n') { - // Special case for multiline comments: join the comment content but - // keep the leading `/*` - - let newline_offset = next.syntax().range().start() - + TextUnit::from(newline_pos as u32) - + TextUnit::of_char('\n'); - - edit.insert(newline_offset, "/*".to_string()); - edit.delete(TextRange::from_to( - node.range().start(), - next.syntax().range().start() + TextUnit::of_str(next.prefix()) - )); - } else { - // Single-line comments - edit.delete(TextRange::from_to( - node.range().start(), - next.syntax().range().start() + TextUnit::of_str(next.prefix()) - )); - } + edit.delete(TextRange::from_to( + node.range().start(), + next.syntax().range().start() + TextUnit::of_str(next.prefix()) + )); } else { // Remove newline but add a computed amount of whitespace characters edit.replace( @@ -356,7 +339,7 @@ fn foo() { } #[test] - fn test_join_lines_multiline_comments() { + fn test_join_lines_multiline_comments_1() { check_join_lines(r" fn foo() { // Hello<|> @@ -369,6 +352,24 @@ fn foo() { "); } + #[test] + fn test_join_lines_multiline_comments_2() { + check_join_lines(r" +fn foo() { + // The<|> + /* quick + brown + fox! */ +} +", r" +fn foo() { + // The<|> quick + brown + fox! */ +} +"); + } + fn check_join_lines_sel(before: &str, after: &str) { let (sel, before) = extract_range(before); let file = File::parse(&before); -- cgit v1.2.3