File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,10 @@ impl<'a> FmtVisitor<'a> {
100
100
}
101
101
102
102
if snippet. trim ( ) . is_empty ( ) && !out_of_file_lines_range ! ( self , span) {
103
+ if self . is_start_span ( span) {
104
+ return ;
105
+ }
106
+
103
107
// Keep vertical spaces within range.
104
108
self . push_vertical_spaces ( count_newlines ( snippet) ) ;
105
109
process_last_snippet ( self , "" , snippet) ;
Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ impl SnippetProvider {
46
46
Some ( & self . big_snippet [ start_index..end_index] )
47
47
}
48
48
49
+ pub ( crate ) fn is_start_span ( & self , span : Span ) -> bool {
50
+ span. lo ( ) . to_usize ( ) == self . start_pos
51
+ }
52
+
49
53
pub ( crate ) fn new ( start_pos : BytePos , end_pos : BytePos , big_snippet : Rc < String > ) -> Self {
50
54
let start_pos = start_pos. to_usize ( ) ;
51
55
let end_pos = end_pos. to_usize ( ) ;
@@ -751,6 +755,10 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
751
755
self . opt_snippet ( span) . unwrap ( )
752
756
}
753
757
758
+ pub ( crate ) fn is_start_span ( & ' b self , span : Span ) -> bool {
759
+ self . snippet_provider . is_start_span ( span)
760
+ }
761
+
754
762
// Returns true if we should skip the following item.
755
763
pub ( crate ) fn visit_attrs ( & mut self , attrs : & [ ast:: Attribute ] , style : ast:: AttrStyle ) -> bool {
756
764
for attr in attrs {
You can’t perform that action at this time.
0 commit comments