File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -144,8 +144,13 @@ impl<'a> FmtVisitor<'a> {
144
144
line_start = offset + subslice. len ( ) ;
145
145
146
146
if let Some ( '/' ) = subslice. chars ( ) . skip ( 1 ) . next ( ) {
147
- // Add a newline after line comments
148
- self . buffer . push_str ( "\n " ) ;
147
+ // check that there are no contained block comments
148
+ if !subslice. split ( '\n' )
149
+ . map ( |s| s. trim_left ( ) )
150
+ . any ( |s| s. len ( ) > 2 && & s[ 0 ..2 ] == "/*" ) {
151
+ // Add a newline after line comments
152
+ self . buffer . push_str ( "\n " ) ;
153
+ }
149
154
} else if line_start <= snippet. len ( ) {
150
155
// For other comments add a newline if there isn't one at the end already
151
156
match snippet[ line_start..] . chars ( ) . next ( ) {
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ // Line Comment
3
+ /* Block Comment */
4
+
5
+ let d = 5 ;
6
+ }
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ // Line Comment
3
+ // Block Comment
4
+
5
+ let d = 5 ;
6
+ }
You can’t perform that action at this time.
0 commit comments