Skip to content

Commit

Permalink
Avoid panic on empty file
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilraojl committed Sep 21, 2023
1 parent 49b907c commit e4529e6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions formatter/src/formatter/mac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,8 @@ pub fn format_macro(
let crlf_line_endings = source
.raw_lines()
.nth(0)
.unwrap()
.to_string()
.ends_with("\r\n");
.map(|raw_line| raw_line.to_string().ends_with("\r\n"))
.unwrap_or_default();
printer = Printer::new(PrinterSettings {
crlf_line_endings,
..settings.into()
Expand Down

0 comments on commit e4529e6

Please sign in to comment.