Skip to content

Commit 834d33c

Browse files
committed
Additional changes needed to prevent adding newline at EOF.
1 parent 76a007b commit 834d33c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/formatting.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,14 @@ impl<'a, T: FormatHandler + 'a> FormatContext<'a, T> {
230230

231231
// For some reason, the source_map does not include terminating
232232
// newlines so we must add one on for each file. This is sad.
233-
source_file::append_newline(&mut visitor.buffer);
233+
let num_newlines = count_newlines(&visitor.buffer);
234+
if self
235+
.config
236+
.file_lines()
237+
.contains_line(&path, num_newlines + 1)
238+
{
239+
source_file::append_newline(&mut visitor.buffer);
240+
}
234241

235242
format_lines(
236243
&mut visitor.buffer,

0 commit comments

Comments
 (0)