File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -215,9 +215,8 @@ impl FileComments {
215215 let split_point = self
216216 . other_comments
217217 . partition_point ( |( ln, _) | * ln <= line_number) ;
218- let comments: Vec < _ > = self . other_comments . drain ( ..split_point) . collect ( ) ;
219218
220- if comments . is_empty ( ) {
219+ if split_point == 0 {
221220 return Some ( (
222221 CommentBlock :: new ( lowest_line..line_number + 1 , Vec :: new ( ) ) ,
223222 starting_line_number,
@@ -227,11 +226,14 @@ impl FileComments {
227226 let mut comment_block_with_spaces: Vec < String > = Vec :: new ( ) ;
228227 let mut last_line = None ;
229228
230- if line_difference_requires_newline ( comments. first ( ) . unwrap ( ) . 0 , starting_line_number) {
229+ if line_difference_requires_newline (
230+ self . other_comments . first ( ) . unwrap ( ) . 0 ,
231+ starting_line_number,
232+ ) {
231233 comment_block_with_spaces. push ( String :: new ( ) ) ;
232234 }
233235
234- for ( index, comment_contents) in comments {
236+ for ( index, comment_contents) in self . other_comments . drain ( ..split_point ) {
235237 if let Some ( last_line) = last_line
236238 && line_difference_requires_newline ( index, last_line)
237239 {
You can’t perform that action at this time.
0 commit comments