@@ -65,11 +65,15 @@ fn remove_newlines(edit: &mut TextEditBuilder, token: &SyntaxToken, range: TextR
6565
6666fn remove_newline ( edit : & mut TextEditBuilder , token : & SyntaxToken , offset : TextSize ) {
6767 if token. kind ( ) != WHITESPACE || token. text ( ) . bytes ( ) . filter ( |& b| b == b'\n' ) . count ( ) != 1 {
68- let mut string_open_quote = false ;
68+ let mut no_space = false ;
6969 if let Some ( string) = ast:: String :: cast ( token. clone ( ) ) {
7070 if let Some ( range) = string. open_quote_text_range ( ) {
71- cov_mark:: hit!( join_string_literal) ;
72- string_open_quote = range. end ( ) == offset;
71+ cov_mark:: hit!( join_string_literal_open_quote) ;
72+ no_space |= range. end ( ) == offset;
73+ }
74+ if let Some ( range) = string. close_quote_text_range ( ) {
75+ cov_mark:: hit!( join_string_literal_close_quote) ;
76+ no_space |= range. start ( ) == offset + TextSize :: of ( '\n' ) ;
7377 }
7478 }
7579
@@ -82,7 +86,7 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextS
8286 } ;
8387
8488 let range = TextRange :: at ( offset, ( ( n_spaces_after_line_break + 1 ) as u32 ) . into ( ) ) ;
85- let replace_with = if string_open_quote { "" } else { " " } ;
89+ let replace_with = if no_space { "" } else { " " } ;
8690 edit. replace ( range, replace_with. to_string ( ) ) ;
8791 return ;
8892 }
@@ -797,22 +801,41 @@ fn foo() {
797801
798802 #[ test]
799803 fn join_string_literal ( ) {
800- cov_mark:: check!( join_string_literal) ;
801- check_join_lines (
802- r#"
804+ {
805+ cov_mark:: check!( join_string_literal_open_quote) ;
806+ check_join_lines (
807+ r#"
803808fn main() {
804809 $0"
805810hello
806811";
807812}
808813"# ,
809- r#"
814+ r#"
810815fn main() {
811816 $0"hello
812817";
813818}
814819"# ,
815- ) ;
820+ ) ;
821+ }
822+
823+ {
824+ cov_mark:: check!( join_string_literal_close_quote) ;
825+ check_join_lines (
826+ r#"
827+ fn main() {
828+ $0"hello
829+ ";
830+ }
831+ "# ,
832+ r#"
833+ fn main() {
834+ $0"hello";
835+ }
836+ "# ,
837+ ) ;
838+ }
816839
817840 check_join_lines (
818841 r#"
0 commit comments